Jump to content

[SOLVED] Cross table reference in SELECT statement


pofigster

Recommended Posts

I'm using MySQL 5.0

 

I'm wondering if the following is possible:  I have one table which has 100 rows and a primary index called 'percent' - everytime a page is loaded I want to select one of these rows (always in order, so, if last time 'percent'=1 was displayed, this time I want 'percent'=2 to display until 'percent'=100 and then I want 'percent'=1 to display again).  I have another table which has one row and one variable called 'curr_perc'  PHP already sends the command to increment this variable each time a page is loaded, but I don't want to do a query to retrieve this value and then another to select the row in the first table - so, is there some way I can say "SELECT * FROM 'adverts' WHERE percent=adv_current.curr_perc" (where adv_current is the table with one row and one variable)?

 

Maybe my idea can be done some other way?

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.