Jump to content

search criteria from array


mdnghtblue

Recommended Posts

$allies = mysql_query("SELECT num, clan FROM players WHERE clan=$users[clan];");

$market = mysql_query("SELECT * FROM market WHERE time<=$time AND seller=$allies;"); // not sure what to put instead of $allies?

 

How can I limit the second query to the sellers with the "num"s selected from the first query? I kinda doubt the way I set it up above works.

Link to comment
Share on other sites

You mean "num" is the ID and seller is the ID from the clan/players table?

 

If so:

 

SELECT p.num, p.clan, m.*
FROM players AS p
INNER JOIN
market AS m ON ( m.seller = p.num )
WHERE m.time<=$time AND p.clan=$users[clan]

 

I'd rename "num"  as player_id and seller as seller_id (or player_id) to make this more obvious.

 

Also, make sure to quote those literals.

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.