I have a large dataset that I need to output in a table for study reasons, I work on a local server. I first wrote this code
mysqli_query($con,"SELECT xxx, yyy, zzz FROM table1 ORDER BY xxx ASC LIMIT 0, 100");
which is ok, it takes one instant to output the values. The problem is i need to join table1 to another table of the same database, so I do this
mysqli_query($con,"SELECT xxx, yyy, zzz FROM table1 INNER JOIN table2 ON table1.yyy=table2.yyy ORDER BY xxx ASC LIMIT 0, 100");
and the query stucks forever.
Is there some coding error? I think no, because I did the same query on a smaller database with the same table structure and it worked.
So, I guess the problem is that when I perform the join all the values from table2 are called and my poor local server doesn't manage to finish the query (also, I notice a huge amount of disk space is used, when second query is performed, an I talk about several GB of space). Is there some way to select only few records from table 2, as I did for table 1? I mean something like SELECT xxx, yyy, zzz FROM table1
and also SELECT yyy, www, aaa FROM table2
and join just these values.
Thanks everyone!
I think is the field conflict,
try
mysqli_query($con,"SELECT xxx, yyy, zzz FROM table1 INNER JOIN table2 ON table1.yyy=table2.yyy ORDER BY YOUR_TABLE.xxx ASC LIMIT 0, 100");