Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 "SELECT AS" vs "SELECT LIKE"

Author  Topic 

Rachel_ch19
Starting Member

5 Posts

Posted - 2010-11-30 : 15:10:07
What's the difference in using them?
I'm a newbie to SQL....
Thanks!

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-30 : 15:36:47
Neither of what you describe is valid SQL syntax. AS is for defining aliases and LIKE is a where clause comparison operator

--
Gail Shaw
SQL Server MVP
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-30 : 15:38:40
There is no such thing as "SELECT LIKE"

AS creates an alias. LIKE is for textual comparisons.

SELECT 1 as [alias]

SELECT * FROM SomeTable WHERE name LIKE 'russell'
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-30 : 15:40:00
Can you post an example where SELECT AS is used and another example where SELECT LIKE is used?
Because it is not clear to me what you need to know...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Rachel_ch19
Starting Member

5 Posts

Posted - 2010-11-30 : 15:46:26
Thank you for your replies!
My understanding now is select ...as gives another name to the subject, and
select like statement is to select sth with certain characteristics.
Right?

Example: select ...as...
select A, count(*) as B into C
from AA

Example: select... like...
SELECT * FROM customers WHERE companyname LIKE 'a%'



Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-30 : 15:52:29
Yes!


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-30 : 16:01:09
quote:
Originally posted by Rachel_ch19

What's the difference in using them?



You can't compare them. They aren't similar. It's apple and oranges here.

Is this a homework question?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -