View Full Version : MYSQL - is this possible
Decode
29-11-2008, 05:45 PM
For a database I have 2 tables setup, they are like-
http://www.tehupload.com/uploads/56561dff5ff9747help.png
I need to order the first table by num (SELECT * FROM `table1` ORDER BY `num` DESC) then I need to match the ID of that to the id in table 2. And it probs needs to be done in 1 mysql query because it needs to be used with mysql_fetch_assoc().
Sorry if what I've said is confusing. I have tried my best to explain it :P
+Rep for any help :)
Thanks.
wsg14
29-11-2008, 05:50 PM
Why not add it all into one table instead of two?
Decode
29-11-2008, 05:55 PM
What I have shown there is a simplyfied example, there is more than 1 of table 1. I am just explaining what the problem is with 2 tables.
Source
29-11-2008, 05:58 PM
It would be better to have it all in 1 table, it wouldn't affect the speed of the site/query. Honestly.
wsg14
29-11-2008, 05:59 PM
nevermind.
Doritos
29-11-2008, 06:02 PM
You can access other things in other tables by table.field, if you didn't already know that.
Decode
29-11-2008, 06:07 PM
It would be better to have it all in 1 table, it wouldn't affect the speed of the site/query. Honestly.
How many rows would there need to be before it starts effecting the speed of my site?
wsg14
29-11-2008, 06:08 PM
How many rows would there need to be before it starts effecting the speed of my site?
I have about 20 rows in my users table, it works fine. You also don't have to worry about speed when all you have is around 7/8 rows.
Decode
29-11-2008, 06:10 PM
I have about 20 rows in my users table, it works fine. You also don't have to worry about speed when all you have is around 7/8 rows.
Where do u get 7/8 rows from lol, I am hoping I will have lots more than that :P
EDIT: I think you have mistaken columns for rows ;)
wsg14
29-11-2008, 06:10 PM
I got it from your diagram, how many rows do you expect to have?
Protege
29-11-2008, 08:26 PM
For a database I have 2 tables setup, they are like-
http://www.tehupload.com/uploads/56561dff5ff9747help.png
I need to order the first table by num (SELECT * FROM `table1` ORDER BY `num` DESC) then I need to match the ID of that to the id in table 2. And it probs needs to be done in 1 mysql query because it needs to be used with mysql_fetch_assoc().
Sorry if what I've said is confusing. I have tried my best to explain it :P
+Rep for any help :)
Thanks.
For table one you should have multi rows so
ID (Article ID)
UserID (The users ID, thats it)
$query = mysql_query( "SELECT * FROM `table1` WHERE `ID` = '213'" );
$peopleVoted = mysql_num_rows( $query );
$f = mysql_fetch_array( $query );
$query_2 = mysql_query( "SELECT * FROM `table2` WHERE `ID` = '" . $f[ 'ID' ] . "' LIMIT 1" );
$r = mysql_fetch_array( $query_2 );
I dont really get it but thats how I see it.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.