![]() |
MySQL the same field from two different rows?
Is it possible to run a MySQL query that will pull the same field but from two different rows? Using two different WHERE clauses? Could someone show me an example of how that would be done?
|
SELECT fieldid FROM table WHERE fieldid IN (1,4,7)
Where 1,4, and 7 are the different rows you are looking for. |
ok lets say this is the code
Code:
SELECT rank FROM table WHERE week=5 |
I'm not sure I follow, you can do:
[sql]SELECT rank FROM [table] WHERE week IN(4,5);[/sql] And they'll show up in their respective rows. Putting them side by side in the same row would be a formatting thing, more cosmetic than anything. I think you'll be better off formatting your results through PHP or whatever language you're using. |
Ok :) so the answer is no...
Thanks. |
Not sure exactly what you mean?
if you want two differnt ones, run 2 seperate quieres. |
You could do this by using a cross join (also referred to as table product):
Code:
SELECT t1.rank, t2.rank FROM table t1, table t2 WHERE t1.week=5 AND t2.week=4 |
Ok thanks Elfmage..
Quote:
|
you could also do a left join for this then
|
All times are GMT. The time now is 05:50 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|