pofigster Posted September 25, 2008 Share Posted September 25, 2008 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 https://forums.phpfreaks.com/topic/125793-solved-cross-table-reference-in-select-statement/ Share on other sites More sharing options...
Barand Posted September 25, 2008 Share Posted September 25, 2008 SELECT a.* FROM adverts a JOIN adv_current c ON a.percent = c.curr_perc Link to comment https://forums.phpfreaks.com/topic/125793-solved-cross-table-reference-in-select-statement/#findComment-650631 Share on other sites More sharing options...
pofigster Posted September 25, 2008 Author Share Posted September 25, 2008 Brilliant! Thank you so much! Link to comment https://forums.phpfreaks.com/topic/125793-solved-cross-table-reference-in-select-statement/#findComment-650645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.