Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Specifying table names
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 10th April 23:37
james
External User
 
Posts: 1
Default Specifying table names



I have a database containing several tables, two of the
tables have an identical column I need to use, in Access I
simply prefix the table name before the sql query,

For example
Tables![TStock]![StockCode]=Tables![TOldStock]![Stockcode]

how do I do this in sql server 7 in a Select query.

IE: Select from blah blah blah....

Thanks to anyone who can help with what must be a simple
questions.
  Reply With Quote


  sponsored links


2 10th April 23:37
vishal parkar
External User
 
Posts: 1
Default Specifying table names



James,
you can prefix column name with the table name if you have identical columns
in the 2 different table
that you are using in query.
See following example on northwind database on SQL Server.

use northwind
go
select a.customerid, b.customerid
from customers a join orders b
on a.customerid = b.customerid

--The above query is as good as

select a.customerid, b.customerid
from customers a ,orders b
where a.customerid = b.customerid

Just remember you will have to prefix the column name with the required
table name alias or table name.
(But if you are using alias for the tables then you will have to prefix
column names with alias only and not table name)
In above examples im using alias for the tables you, can replace alias with
the table names as well. Which will
turn above query as

select customers.customerid, orders.customerid
from customers ,orders
where customers.customerid = orders.customerid

Search in Books online for following topic which will answer almost all of
your questions.

"SELECT Examples"


--
-Vishal
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666