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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.