SQL Working time and php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Komp
Forum Newbie
Posts: 4
Joined: Thu Mar 12, 2009 11:42 am

SQL Working time and php

Post by Komp »

Hey guys,

I've been thinking about what kinds query are faster and what kinds of query are slower in general terms?

Example:

What would be faster:
1)
SELECT id FROM table_name WHERE email = 'example@email.com'
SELECT address FROM another_table WHERE id_person = 'some id'

OR

2)
SELECT a.id, b.address FROM table_name a, another_table b WHERE a.email = 'example@email.com', b.id_person = 'some_id'

In this case we've got 2 queries performed seperatly and the same result in only 1 query.
I know, this example, just like that, almost doesn't make sense, this is an example only!

May be there are some queries I should avoid using?

If I'm missing something, please tell me and/or correct me :)

I am really newbe at this...

Thanks for your help :wink:
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: SQL Working time and php

Post by iamngk »

Do you have mysql manual? If yes, kindly go through following topic.
7.2. Optimizing SELECT and Other Statements
It will give you clear idea in different type of query.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: SQL Working time and php

Post by Griven »

Komp
Forum Newbie
Posts: 4
Joined: Thu Mar 12, 2009 11:42 am

Re: SQL Working time and php

Post by Komp »

got it!

Thx guys :D
Post Reply