woolyg Posted June 30, 2008 Share Posted June 30, 2008 Hi, Could someone please give me a dig out with the SQL query I need to make? I have a table that goes as follows: ID | name1 | score1 | name2 | score2 | name3 | score3 I need to select info from a line that says "select name(x), where score(x)=1" - eg - if score1='1', return name1 - if score2='1', also return name2 - if score3='1', also return name3 Can anyone help? Thanks, WoolyG Quote Link to comment Share on other sites More sharing options...
dmccabe Posted June 30, 2008 Share Posted June 30, 2008 I think this would work better if you split it into 2 tables Names | Scores And structured each table like this: tbl_Names ID | Name tbl_Scores ID | Score | Name_ID then you would use: SELECT * FROM `tbl_Scores` WHERE `score` = 'x' $Name_ID = $row['Name_ID']; SELECT * FROM `tbl_Name` WHERE `ID` = '$Name_ID' That is a very rough example Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.