Question : mysql SQL question

1.Please tell me the query to find the 5th record in a table?

2.please tell me the query to compare 2 tables and ensure both has same records?

3.If a query is running slow what are the things i need to consider?

Answer : mysql SQL question

1. select * from Tab order by Name limit 4,1

2. afaik, there is no simple query that will do that. If you by "same records" mean the same record id, try this:

select t1.* from t1 left join t2 using(id) where t2.id is null;
select t2.* from t2 left join t1 using(id) where t1.id is null;

If both queries returns no records, the id columns are the same in both tables. If either query returns rows, those rows do not exist in the other table. If you by "same records" mean all columns are identical, you must list all columns in the queries:

select t1.* from t1 left join t2 using(id,col1,col2,col3,col4) where t2.id is null;
select t2.* from t2 left join t1 using(id,col1,col2,col3,col4) where t1.id is null;

3. Indexing. Use EXPLAIN to analyze the query

http://dev.mysql.com/doc/refman/5.0/en/using-explain.html
Random Solutions  
 
programming4us programming4us