[thelist] Free Tip about SQL
Sarah
poohbear at designshift.com
Fri Jul 18 14:55:47 CDT 2003
>>I usually do something like:
>>
>>SELECT id
>>FROM users
>>WHERE username = 'chris'
>> AND coolfactor = 'infinite'
>> AND babemagnet = 'yes';
>>
>>(we are assuming that) chris, infinite, and yes all came from
>>information that was passed to a form on a website.
>
>Actually, this isn't guaranteed to work at all, simply because you're
>assuming that your record is unique. In a talbe with a large number of
>fields, you really don't want to be doing a where clause on every field.
>(Sure as hell on on large text or binary fields, performance will drop
>like shares in Enron.)
>
>Stick to whatever mechanism your DB provides. It might not be as 100%
>portable, but it is guaranteed to work every time, which all of these
>other methods are not.
I usually do something similar to Chris's example, but I would use MAX(id)
in case their is a duplicate record in the database already.
Sarah
More information about the thelist
mailing list