Comment On A Confusing SELECTion

It was Anthony's second day on the job, and the sixth time he thought to himself, What The Fuuuuuhhhggggg, while searching through the code. At least, he thought that he kept that last sentiment to himself. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: A Confusing SELECTion

2009-08-10 09:02 • by lyates
select first from comments;

Let me be the first to say...

2009-08-10 09:02 • by Arkady Bogdanov (unregistered)
What The Fuuuuuhhhggggg

Re: A Confusing SELECTion

2009-08-10 09:11 • by Crash Magnet (unregistered)
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?

Re: A Confusing SELECTion

2009-08-10 09:15 • by Anonymous Coward (unregistered)
281728 in reply to 281727
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


It's multiple select statements when a single select will work just as well, and without all the declared variables, too.

Re: A Confusing SELECTion

2009-08-10 09:17 • by rocksinger (unregistered)
281729 in reply to 281727
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


The TSQL function ISNULL(@variable,'') returns '' if @variable is null.

You could also argue that it's the front-end/mid-layer's job to deal with nulls.

Re: A Confusing SELECTion

2009-08-10 09:17 • by Bri (unregistered)
Also note that isnull is not index-friendly, so it is probably a bit slower than it should be.

Re: A Confusing SELECTion

2009-08-10 09:19 • by rocksinger (unregistered)
281731 in reply to 281729
eeek, I meant

The TSQL function ISNULL(YourFieldName,'') returns '' if YourFieldName is null.

Re: A Confusing SELECTion

2009-08-10 09:21 • by Huh? (unregistered)
select @w = w from wtf where id = @id
select @t = t from wtf where id = @id
select @f = f from wtf where id = @id

select @w + @t + @f

Re: A Confusing SELECTion

2009-08-10 09:26 • by jonsjava
declare @lnFirstName varchar(255)
declare @lnLastName varchar(255)
declare @lnEmailaddr varchar(255)
declare @lnTitle varchar(255)
declare @lnCompany varchar(255)
declare @lnAddress varchar(255)
declare @lnCity varchar(255)
declare @lnState varchar(255)
declare @lnZip varchar(255)
declare @lnCountry varchar(255)
declare @lnPhone varchar(255)
declare @lnFax varchar(255)

Ok, I know that the USPS isn't the most efficient, but I can't think of the last time I saw a zip code longer than 10 (5didgit, dash, +4). Phone number being 255? wow. I'd hate to see the phone bill associated with that long distance call.....

I was going to go all witty with this, but there are too many WTFs associated with this.

Re: A Confusing SELECTion

2009-08-10 09:31 • by Sandor (unregistered)
281734 in reply to 281728
Anonymous Coward:
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


It's multiple select statements when a single select will work just as well, and without all the declared variables, too.


Yes, but then any non-developer who looks at the code thinks that writing code is easy.

BTW anyone who names tables "Sitr0110" should be shot.

CAPTCHA: ********

Re: A Confusing SELECTion

2009-08-10 09:31 • by tin
281735 in reply to 281733
jonsjava:
Phone number being 255? wow.


A pre-scripted phone banking session could get that long... Though I can't think of a legal reason to store that in a database with people's names and addresses...

Re: A Confusing SELECTion

2009-08-10 09:35 • by Aaron
281737 in reply to 281730
Bri:
Also note that isnull is not index-friendly, so it is probably a bit slower than it should be.

Um, no?

There is actually no non-trivial function that is "index-friendly" if used as part of a WHERE clause - only the columns themselves are indexed, and if you chuck it into any function, the optimizer has to scan the whole index. But applying a function to the query's output has almost no effect on performance unless the function itself is extremely slow, which ISNULL definitely isn't.

This entire hunk of junk could have been written as one SELECT statement with a bunch of ISNULLs, and would run in about 1/50th of the time. Of course, the fact that nulls are being turned into empty strings suggests an even worse WTF somewhere in the code, unless this is being directly used to feed a report (and nothing else). And then you have all the varchar(255) columns, but that's the least of our worries here...

Re: A Confusing SELECTion

2009-08-10 09:41 • by Ron Moses (unregistered)
To put it in simpler terms, let's say you want to buy a dozen donuts. You tell the clerk which donuts you want; he takes each donut from the case and places it in a separate bag. Once he's got all twelve bags lined up on the counter in front of him, each with a single donut in it, he opens each bag in turn and puts the donut into a dozen box. Once all twelve donuts are in the box, he closes it and hands it to you.

Then his co-worker, noticing your puzzled expression, comes along and explains that it's better to do it this way in case you change your mind about one of the donuts and he has to swap it out. And you look at him, and the clerk, and realize the two of them have been doing crack all morning. The end.

Re: A Confusing SELECTion

2009-08-10 09:47 • by operagost
281739 in reply to 281738
Ron Moses:
And you look at him, and the clerk, and realize the two of them have been doing crack all morning. The end.

WIN

Re: A Confusing SELECTion

2009-08-10 09:51 • by A Nonny Mouse
281740 in reply to 281733
jonsjava:
I was going to go all witty with this, but there are too many WTFs associated with this.

yeah exactly. besides the many many things wrong with this, what's with all the unnecessary begins and ends?

Re: A Confusing SELECTion

2009-08-10 09:57 • by campkev
281741 in reply to 281727
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


Um, where to start? Let's see, there's this mess
select

@lnSitr0100Id = max([Sitr0100Id])
from
Sitr0110
where
[Sitr0110Id] = @lnSitr0110Id
which does absolutely nothing.


But the major WTF is that this whole page long crapfest could be written as:
select @lnSitr0110Id as Response,

IsNull(FirstName,'') as First,
IsNull(LastName,'') as Last,
IsNull(EmailAddress,'') as Email,
IsNull(Title,'') as Title,
IsNull(Company,'') as Company,
IsNull(Address1,'') as Address,
IsNull(City,'') as City,
IsNull(State,'') as State,
IsNull(Zip,'') as Zip,
IsNull(Country,'') as Country,
IsNull(Phone,'') as Phone,
IsNull(Fax,'') as Fax,
@lnNew as New,
@lnSitr0100Id as Sitr0100Id
where Sitr0100Id = @lnSitr0100Id

Re: A Confusing SELECTion

2009-08-10 10:01 • by Bodestone
281742 in reply to 281740
A Nonny Mouse:

yeah exactly. besides the many many things wrong with this, what's with all the unnecessary begins and ends?


I always wrap my condiational code in BEGIN and END in SQL (and other where you only need it for multi-liners), even if it's a one liner.

There is no performance issue and it means you are using the same convention for all condition statements.

Not to mention the cut and paste issues I've seen with people who don't.

Re: A Confusing SELECTion

2009-08-10 10:02 • by SR (unregistered)
281743 in reply to 281741
campkev:
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


Um, where to start? Let's see, there's this mess
select

@lnSitr0100Id = max([Sitr0100Id])
from
Sitr0110
where
[Sitr0110Id] = @lnSitr0110Id
which does absolutely nothing.


But the major WTF is that this whole page long crapfest could be written as:
select @lnSitr0110Id as Response,

IsNull(FirstName,'') as First,
IsNull(LastName,'') as Last,
IsNull(EmailAddress,'') as Email,
IsNull(Title,'') as Title,
IsNull(Company,'') as Company,
IsNull(Address1,'') as Address,
IsNull(City,'') as City,
IsNull(State,'') as State,
IsNull(Zip,'') as Zip,
IsNull(Country,'') as Country,
IsNull(Phone,'') as Phone,
IsNull(Fax,'') as Fax,
@lnNew as New,
@lnSitr0100Id as Sitr0100Id
where Sitr0100Id = @lnSitr0100Id


I agree to a certain extent, though I'd argue that the application should deal with nulls.

Either way: W? T? F?

Re: A Confusing SELECTion

2009-08-10 10:05 • by Engival (unregistered)
281744 in reply to 281741
campkev:
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


Um, where to start? Let's see, there's this mess
select

@lnSitr0100Id = max([Sitr0100Id])
from
Sitr0110
where
[Sitr0110Id] = @lnSitr0110Id
which does absolutely nothing.


You're missing the subtle difference between 0110 and 0100. Any interaction between those tables must be pure joy to work with.

Re: A Confusing SELECTion

2009-08-10 10:05 • by ubersoldat
I like donuts... and crack...

Re: A Confusing SELECTion

2009-08-10 10:07 • by Anonymous (unregistered)
281746 in reply to 281738
Ron Moses:
To put it in simpler terms, let's say you want to buy a dozen donuts. You tell the clerk which donuts you want; he takes each donut from the case and places it in a separate bag. Once he's got all twelve bags lined up on the counter in front of him, each with a single donut in it, he opens each bag in turn and puts the donut into a dozen box. Once all twelve donuts are in the box, he closes it and hands it to you.

Then his co-worker, noticing your puzzled expression, comes along and explains that it's better to do it this way in case you change your mind about one of the donuts and he has to swap it out. And you look at him, and the clerk, and realize the two of them have been doing crack all morning. The end.
So can I swap one of the donuts for a big bag of crack? Sounds like they're set up to accomodate such a situation and I don't really need all twelve donuts. Eleven donuts and a big bag of crack should keep me occupied just fine for the whole rest of the day.

Re: A Confusing SELECTion

2009-08-10 10:08 • by RonMexico (unregistered)
281747 in reply to 281742
Bodestone:
A Nonny Mouse:

yeah exactly. besides the many many things wrong with this, what's with all the unnecessary begins and ends?


I always wrap my condiational code in BEGIN and END in SQL (and other where you only need it for multi-liners), even if it's a one liner.

There is no performance issue and it means you are using the same convention for all condition statements.

Not to mention the cut and paste issues I've seen with people who don't.

Ditto. I use braces in C#/Javascript for single-line if and loop clauses also. Clarity, maintainability, all that.

Re: A Confusing SELECTion

2009-08-10 10:11 • by Mike Dimmick (unregistered)
It's rather like your partner giving you a shopping list and instead of driving to the shop, buying everything on the list and returning home, you instead drive to the shop, buy the first item, drive home, drop it off, drive back to the shop, buy the second item, drive home, etc.

If you're using SQL you should aim to retrieve all the values you need in one statement. It helps if you understand that the database has to work pretty hard to find any particular row, but virtually no extra effort to retrieve additional values associated with that row.

This particular query could have been rewritten as:
SELECT TOP 1

Sitr0100Id AS Response,
FirstName AS First,
LastName AS Last,
EmailAddress AS Email,
Title,
Company,
Address1 AS Address,
City,
State,
Country,
Phone,
NULL AS New, -- @lnNew isn't set
Sitr0100Id AS Sitr0100Id
FROM
Sitr0100
ORDER BY Sitr0100Id DESC

(ordering by the ID in reverse and taking the top result is the same as selecting MAX(Sitr0100Id))

Re: A Confusing SELECTion

2009-08-10 10:15 • by campkev
281749 in reply to 281744
Engival:
campkev:
Crash Magnet:
For those of us who don't speak sql, what the Fuuuuuhhhggggg is wrong with this?


Um, where to start? Let's see, there's this mess
select

@lnSitr0100Id = max([Sitr0100Id])
from
Sitr0110
where
[Sitr0110Id] = @lnSitr0110Id
which does absolutely nothing.


You're missing the subtle difference between 0110 and 0100. Any interaction between those tables must be pure joy to work with.

Crap, you're right. Add dumbass table names to the list of WTF's

Re: A Confusing SELECTion

2009-08-10 10:21 • by Bodestone
And why do all the variables start @ln, or is it @In?

That's dafter than tables starting tbl.

Re: A Confusing SELECTion

2009-08-10 10:27 • by Dana (unregistered)
281751 in reply to 281750
It's standard practice to name SQL variables beginning with @.

Re: A Confusing SELECTion

2009-08-10 10:27 • by Patrick (unregistered)
$sp=' ';
$comment1='this'.$sp;
$comment2='way'.$sp;
$comment3='you'.$sp;
$comment4='can'.$sp;
$comment5='swap'.$sp;
$comment6='words'.$sp;
$comment7='around';
$comment=$comment1.$comment2.$comment3.$comment4.$comment5.$comment6.$comment7.'.';
echo $comment;

Re: A Confusing SELECTion

2009-08-10 10:32 • by snoofle
281753 in reply to 281733
jonsjava:
declare @lnFirstName varchar(255)
declare @lnLastName varchar(255)
declare @lnEmailaddr varchar(255)
declare @lnTitle varchar(255)
declare @lnCompany varchar(255)
declare @lnAddress varchar(255)
declare @lnCity varchar(255)
declare @lnState varchar(255)
declare @lnZip varchar(255)
declare @lnCountry varchar(255)
declare @lnPhone varchar(255)
declare @lnFax varchar(255)

Ok, I know that the USPS isn't the most efficient, but I can't think of the last time I saw a zip code longer than 10 (5didgit, dash, +4). Phone number being 255? wow. I'd hate to see the phone bill associated with that long distance call.....

I was going to go all witty with this, but there are too many WTFs associated with this.

You should see the phone bills we get here at StarFleet!

Re: A Confusing SELECTion

2009-08-10 10:33 • by Junkie
281754 in reply to 281745
ubersoldat:
I like donuts... and crack...
Donuts with powdered crack - yummy!

Re: A Confusing SELECTion

2009-08-10 10:34 • by Junkie
281755 in reply to 281748
Mike Dimmick:
It's rather like your partner giving you a shopping list and instead of driving to the shop, buying everything on the list and returning home, you instead drive to the shop, buy the first item, drive home, drop it off, drive back to the shop, buy the second item, drive home, etc.

If you're using SQL you should aim to retrieve all the values you need in one statement. It helps if you understand that the database has to work pretty hard to find any particular row, but virtually no extra effort to retrieve additional values associated with that row.

This particular query could have been rewritten as:
SELECT TOP 1

Sitr0100Id AS Response,
FirstName AS First,
LastName AS Last,
EmailAddress AS Email,
Title,
Company,
Address1 AS Address,
City,
State,
Country,
Phone,
NULL AS New, -- @lnNew isn't set
Sitr0100Id AS Sitr0100Id
FROM
Sitr0100
ORDER BY Sitr0100Id DESC

(ordering by the ID in reverse and taking the top result is the same as selecting MAX(Sitr0100Id))
Not to mention the chance that the data in the row may change between calls.

Re: A Confusing SELECTion

2009-08-10 10:38 • by Beaker (unregistered)
281756 in reply to 281750
I originally thought it could be some sort of Hungarian Notation (some find that to be a bad practice too), but there's no rhyme or reason to the prefix.

As for the isNull function, the code base that is calling the SQL statement should be handling those nulls. It's one thing if you have to concatenate values in the query (concatenating a string and a null in SQL yields a null), but that's not the case here.

Re: A Confusing SELECTion

2009-08-10 10:39 • by SR (unregistered)
281758 in reply to 281751
Dana:
It's standard practice to name SQL variables beginning with @.


Although you have to admit an overuse of "In" and "ln" is WTFery of the highest order.

Re: A Confusing SELECTion

2009-08-10 10:50 • by Patrick (unregistered)
281759 in reply to 281750
Bodestone:
And why do all the variables start @ln, or is it @In?

That's dafter than tables starting tbl.

That's nothing, I have to deal with all tables starting with "table_", which gets picked up by the syntax checker before I'm finished.
Prefixing names (or Hungarian Notation, in this case) is useful only for form controls when you want to tell the difference between txtSearch and btnSearch. Other than that, it's usually a sign of an incoming wtf-bomb.

Re: A Confusing SELECTion

2009-08-10 10:58 • by Ken B (unregistered)
281760 in reply to 281738
Ron Moses:
To put it in simpler terms, let's say you want to buy a dozen donuts. You tell the clerk which donuts you want; he takes each donut from the case and places it in a separate bag. Once he's got all twelve bags lined up on the counter in front of him, each with a single donut in it, he opens each bag in turn and puts the donut into a dozen box. Once all twelve donuts are in the box, he closes it and hands it to you.
Close, but not quite.

It's more like the clerk takes a bag, goes to the donuts, places one in the bag, and then puts the bag in a table in back. He then gets another bag, goes to the donuts, places one in the bag, and then puts the bag in a table in back. Repeat.

(ie: Your version could be done by taking twelve bags and placing one donut in each, whereas the entire "take a bag, put a donut in it, and put the bag in a temporary storage area" needs to be completely done, from start to finish, twelve separate times.)

Re: A Confusing SELECTion

2009-08-10 11:00 • by akatherder
I don't know if this is better or worse than:


$rs = $myconn.execute("Select * from sitr0100");

for ($i=0; $<$rs.length(); $i++)
{
if ($rs["id"]==$myId)
{
$firstname = $rs["FirstName"];
$lastname = $rs["LastName"];
$email = $rs["EmailAddress"];
etc..
}
}

Re: A Confusing SELECTion

2009-08-10 11:01 • by Ken B (unregistered)
281762 in reply to 281745
ubersoldat:
I like donuts... and crack...
Then you probably love plumbers on their lunch break. :-)

Re: A Confusing SELECTion

2009-08-10 11:08 • by Ken B (unregistered)
281763 in reply to 281761
akatherder:
I don't know if this is better or worse than:


$rs = $myconn.execute("Select * from sitr0100");

for ($i=0; $<$rs.length(); $i++)
{
if ($rs["id"]==$myId)
{
$firstname = $rs["FirstName"];
$lastname = $rs["LastName"];
$email = $rs["EmailAddress"];
etc..
}
}
"WHERE clause"? What's a "WHERE clause"?

Re: A Confusing SELECTion

2009-08-10 11:20 • by rfsmit
281765 in reply to 281747
RonMexico:
Bodestone:
A Nonny Mouse:

yeah exactly. besides the many many things wrong with this, what's with all the unnecessary begins and ends?


I always wrap my condiational code in BEGIN and END in SQL (and other where you only need it for multi-liners), even if it's a one liner.

There is no performance issue and it means you are using the same convention for all condition statements.

Not to mention the cut and paste issues I've seen with people who don't.

Ditto. I use braces in C#/Javascript for single-line if and loop clauses also. Clarity, maintainability, all that.

And for the same reason, when I'm done testing with
[[ $? -ne 0 ]] && failed || success
I unroll that into
if [ $? -ne 0 ]; then

failed
else
success
fi
It's only polite.

Re: A Confusing SELECTion

2009-08-10 11:39 • by Yazeran (unregistered)
281766 in reply to 281748
Mike Dimmick:

(ordering by the ID in reverse and taking the top result is the same as selecting MAX(Sitr0100Id))


Fail!

In output yes, but in performance NO!
Max() / Min() is O(n) whereas sort (ORDER) is at best O(n log(n))

For small n it doesn't matter, but for large n.....

In this particular case it likely doesn't matter (as the application will likely be slow as molasses anyways considering that SQL) :-)


Yours Yazeran.

Plan: To go to Mars one day with a hammer.

Re: A Confusing SELECTion

2009-08-10 11:40 • by JoeKu (unregistered)
281767 in reply to 281741
campkev:
select @lnSitr0110Id as Response,

IsNull(FirstName,'') as First,

IsNull(LastName,'') as Last,

IsNull(EmailAddress,'') as Email,

IsNull(Title,'') as Title,

IsNull(Company,'') as Company,

IsNull(Address1,'') as Address,

IsNull(City,'') as City,

IsNull(State,'') as State,

IsNull(Zip,'') as Zip,

IsNull(Country,'') as Country,

IsNull(Phone,'') as Phone,

IsNull(Fax,'') as Fax,

@lnNew as New,

@lnSitr0100Id as Sitr0100Id

where Sitr0100Id = @lnSitr0100Id



Almost correct: if there are no rows where Sitr0100Id = @lnSitr0100Id, then your select will return an empty resultset. If there are multiple rows with the specified condition, then your select will return multiple rows. The original code will always return 1 row.

Of course, it make sense for the caller to deal with the non-existing row as an empty resultset, but your code is not 100% compatible with the original code.

Re: A Confusing SELECTion

2009-08-10 11:43 • by A DBA (unregistered)
281768 in reply to 281734
Sandor:
BTW anyone who names tables "Sitr0110" should be shot.


Okay! Okay! I'll change the name of the table to "babysitters_born_jan_10"! Don't shoot! Please!

Re: A Confusing SELECTion

2009-08-10 11:57 • by jasmine2501
281769 in reply to 281730
Isnull doesn't matter a whole lot unless it's used in the WHERE clause. In the SELECT clause, it only adds a "compute scalar" to the query plan.

But still... this is why we need to actually test people who SAY they know SQL... because usually, they don't. In an interview I was given once, I was told I was the only person who ever passed their SQL test, and it was ridiculously easy, but I wasn't surprised that nobody did well on it because they were looking for C# programmers, who also "know SQL"

Re: A Confusing SELECTion

2009-08-10 12:07 • by ppp (unregistered)
281770 in reply to 281733
jonsjava:
declare @lnFirstName varchar(255)
declare @lnLastName varchar(255)
declare @lnEmailaddr varchar(255)
declare @lnTitle varchar(255)
declare @lnCompany varchar(255)
declare @lnAddress varchar(255)
declare @lnCity varchar(255)
declare @lnState varchar(255)
declare @lnZip varchar(255)
declare @lnCountry varchar(255)
declare @lnPhone varchar(255)
declare @lnFax varchar(255)

Ok, I know that the USPS isn't the most efficient, but I can't think of the last time I saw a zip code longer than 10 (5didgit, dash, +4). Phone number being 255? wow.


Meh. Our production db is full of "boolean" fields that are VARCHAR2(255). Not only that, we have one table (incrementally modified over the years by different developers) with four VARCHAR2(255) fields constrained to:
1. "1" or "0"
2. "TRUE" or "FALSE"
3. "YES" or "NO"
4. "Y" or "N"

I'm not kidding. This isn't written for effect.

As for me, I insist on using NUMBER(0, 1) for my booleans. Sure, it's another version, but at least it's right.

Re: A Confusing SELECTion

2009-08-10 12:35 • by Ibi-Wan Kentobi (unregistered)
281771 in reply to 281766
Yazeran:
Mike Dimmick:

(ordering by the ID in reverse and taking the top result is the same as selecting MAX(Sitr0100Id))


Fail!

In output yes, but in performance NO!
Max() / Min() is O(n) whereas sort (ORDER) is at best O(n log(n))

For small n it doesn't matter, but for large n.....


If you were searching through a flat file yes, but in a database NO!

Max(), Min(), and SELECT TOP 1 FROM ... ORDER BY are all O(1) in a table indexed by the field in question -- which this table certainly should be, given this usage.

Re: A Confusing SELECTion

2009-08-10 12:37 • by Salami
The best part is that the coworker had no problem with it.

Re: A Confusing SELECTion

2009-08-10 12:40 • by jgreen
281773 in reply to 281746
Anonymous:
Ron Moses:
To put it in simpler terms, let's say you want to buy a dozen donuts. You tell the clerk which donuts you want; he takes each donut from the case and places it in a separate bag. Once he's got all twelve bags lined up on the counter in front of him, each with a single donut in it, he opens each bag in turn and puts the donut into a dozen box. Once all twelve donuts are in the box, he closes it and hands it to you.

Then his co-worker, noticing your puzzled expression, comes along and explains that it's better to do it this way in case you change your mind about one of the donuts and he has to swap it out. And you look at him, and the clerk, and realize the two of them have been doing crack all morning. The end.
So can I swap one of the donuts for a big bag of crack? Sounds like they're set up to accomodate such a situation and I don't really need all twelve donuts. Eleven donuts and a big bag of crack should keep me occupied just fine for the whole rest of the day.


DOUBLE WIN

Re: A Confusing SELECTion

2009-08-10 12:40 • by Ibi-Wan Kentobi (unregistered)
281774 in reply to 281770
ppp:

As for me, I insist on using NUMBER(0, 1) for my booleans. Sure, it's another version, but at least it's right.


And the nominee for The New Real WTF is...

(You don't think the first four people all thought "at least MINE is right"?)

Re: A Confusing SELECTion

2009-08-10 12:50 • by Coward (unregistered)
281776 in reply to 281770
ppp:
(snip) As for me, I insist on using NUMBER(0, 1) for my booleans. Sure, it's another version, but at least it's right.


Why would you use a decimal?

Wouldn't it make more sense to use a NUMBER(1)?

Re: A Confusing SELECTion

2009-08-10 13:23 • by Sandor (unregistered)
281778 in reply to 281768
A DBA:
Sandor:
BTW anyone who names tables "Sitr0110" should be shot.


Okay! Okay! I'll change the name of the table to "babysitters_born_jan_10"! Don't shoot! Please!


Ow great! now i can use SELECT * FROM babysitters_born_jan_10 in stead of:

SELECT h.* FROM HUMANS
INNER JOIN JobDescriptions j on j.ID = h.JobDescriptionID
WHERE j.Description = 'Babysitter'
AND DATEPART (m, h.BirthDay) = 1
AND DATEPART (d, h.BirthDay) = 10

which allows for much faster coding :) and a lot of tables *yeah*

Re: A Confusing SELECTion

2009-08-10 13:31 • by Code Dependent
281779 in reply to 281745
ubersoldat:
I like donuts... and crack...
Here ya go.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment