Jump to content

SQL query help


woolyg

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/112546-sql-query-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/112546-sql-query-help/#findComment-578149
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.