开发者

joining 2 columns in 1 table

开发者 https://www.devze.com 2023-02-25 18:59 出处:网络
Im not sure of the right way to do this so help needed if possible please :) I have a table of football fixtures with the following fields:

Im not sure of the right way to do this so help needed if possible please :)

I have a table of football fixtures with the following fields:

id, hteam, ateam, hscore, as开发者_开发技巧core, date, time

I want to return all the fixtures for one team so where hteam OR ateam = 1 but this doesnt seem to work.

Is there a way I can join or merge these 2 columns to get all the fixture for a particular team?

thanks in advance :)


So to clarify, you have a single table, and you want to return the row if hteam or ateam is 1? If so, something like SELECT * FROM table WHERE hteam=1 OR ateam=1


if u want that if ateam = 1 then show ateam column otherwise hteam column then try

SELECT id, hscore, ascore, date, time,
    IF(ateam=1,atem,hteam) AS fixture ,
FROM  fixtures
0

精彩评论

暂无评论...
验证码 换一张
取 消