Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2010, 03:44 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , Pakistan.
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default How to make a query which use column and table aliases but not using joins

How to make a query which use column and table aliases but not using joins
Select channel_id AS "ClAlias" from tblchannel TbAlias where tblaias.IS_DEFAULT = 1;
Giving error of invalid identifier, how can I make such a query which uses both table and column aliases but not related to joins.
My separate table alias and column aliases queries are working fine:
(Table alias query)
SELECT CHANNEL_ID, IS_DEFAULT from tblchannel ImTbAlias WHERE ImTbAlias.IS_DEFAULT = 1;
(Column alias query)
Select channel_id "ImClAlias" from tblchannel;
Thanks in advance.
__________________
How to do programming?
 
Old October 26th, 2010, 03:43 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

The kind of "quote marks" you can use around named depends on what database you are using. And also what the "settings" in that database are.

But for a name such as CIAlias you don't need any marks.

You should be able to just use
Code:
Select channel_id AS ClAlias from tblchannel AS TbAlias where tbAlias.IS_DEFAULT = 1;
You only need "quote marks" around aliases if the aliases are the same as keywords in the DB you are using.

Note: For MySQL, you need to use `...` marks (those are "back ticks"...they are *NOT* apostrophes!). For Access, you need to use [...]. For SQL Server, whether you can use "..." or not depends on a setting in the DB.
The Following User Says Thank You to Old Pedant For This Useful Post:
arbab (October 27th, 2010)
 
Old October 27th, 2010, 01:37 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , Pakistan.
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default Thanks for your elaborate answer.

Thanks for your elaborate answer.
__________________
How to do programming?




Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Table Query CongoGrey Access 2 June 1st, 2007 06:22 AM
Can a Make Table Query produce a Linked table? kronik Access 5 May 16th, 2006 06:17 AM
Make Table query : table in Another Database marnik Access 1 March 19th, 2005 12:39 PM
how to make column of table 1 = to column of table gilgalbiblewheel Classic ASP Databases 4 October 11th, 2004 11:57 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.