20+ queries when posting

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
User avatar
chAos
Registered User
Posts: 259
Joined: Wed Jan 16, 2002 7:05 am

Re: 20+ queries when posting

Post by chAos »

Code: Select all

<?php $sql1 = "SELECT userid, username FROM phpbb_users";

#- OR -#

$sql2 = "SELECT userid FROM phpbb_users";
$sql3 = "SELECT username FROM phpbb_users"; ?>

In this case the first one is more practical, although you already knew that. :)

PS. i'm already loving the syntax highlighting. :D
Last edited by chAos on Thu Jan 01, 1970 12:00 am, edited 2 times in total.
User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: 20+ queries when posting

Post by psoTFX »

ChAoS wrote:In this case the first one is more practical, although you already knew that. :)
Really?! My God, I'll rewrite all our sql immediately ... ;) That's obviously not what I or indeed SHS` were saying. You can have multiple joins on tables doing complex comparisons across multiple fields which take an age to complete even with appropriate indexing ... meanwhile, the same query broken down into two or more queries may execute faster.
User avatar
chAos
Registered User
Posts: 259
Joined: Wed Jan 16, 2002 7:05 am

Re: 20+ queries when posting

Post by chAos »

You know more about SQL than me, so i trust you.

On a lighter note, i've just been learning about the more advanced sql queries, like:

Code: Select all

SELECT w.*, u.* FROM phpbb_warnings w, phpbb_users u WHERE w.warn_userid = u.user_id
I think that should work. :)

Anyway, i've been proven wrong. ;)
User avatar
dhn
Registered User
Posts: 1518
Joined: Wed Jul 04, 2001 8:10 am
Location: Around the corner
Contact:

Re: 20+ queries when posting

Post by dhn »

If you call that advanced Chaos, you still have a lot to learn (not meant as an insult). :) Wait till you get to joins.
Image
Aexoden
Registered User
Posts: 118
Joined: Tue Oct 08, 2002 5:21 pm
Location: Spokane, WA
Contact:

Re: 20+ queries when posting

Post by Aexoden »

At this point, when I write queries, I tend to write simple ones and then do processing in PHP. Of course, this isn't because that method isn't inherently better, but because the only SQL I know is what I learned from phpBB and a brief exposure to some kind of JOIN when I was doing something that I can no longer recall. I have yet to see the power of some of the more advanced SQL queries. Shame that the advanced queries tend to be the ones I remember phpBB naysayers complaining about. e.g. "Oh no! You're using a JOIN on your posts table. Ahhhh!" etc. So I really have no idea whether JOINS are useful to be used in the real-world environment. Must be time for a relational database theory book or something.
Darkshines
Registered User
Posts: 40
Joined: Thu Jan 24, 2002 7:14 pm
Location: Leyland, Lancashire

Re: 20+ queries when posting

Post by Darkshines »

dhn wrote:If you call that advanced Chaos, you still have a lot to learn (not meant as an insult). :) Wait till you get to joins.
That is a join, isn't it? :P

The thing that had me confused first time I had to do it was "Group by". Not that you need to use it all that much though.
Then again...
Post Reply