473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Update sql syntex question

rc
Hi

I am kind of new to sql, so here goes my question

I have this sql update query

update [CACI-table] set premeses=[xaa].[Sub Building]
where (premeses is null)

Waht is wrong with this.

I have tow table called xaa and CACI-table and all I want to do is
take one column from one table and and put itto the other

Query analysider says the following err message

The column prefix 'xaa' does not match with a table name or alias name
used in the query.
Jul 20 '05 #1
4 2058
<rc@die@you@!spammers.sandworm.demon.co.uk> wrote in message
news:nl********************************@4ax.com...
Hi

I am kind of new to sql, so here goes my question

I have this sql update query

update [CACI-table] set premeses=[xaa].[Sub Building]
where (premeses is null)

Waht is wrong with this.

I have tow table called xaa and CACI-table and all I want to do is
take one column from one table and and put itto the other

Query analysider says the following err message

The column prefix 'xaa' does not match with a table name or alias name
used in the query.


You need to use a FROM clause. I can't give you the exact query because you
haven't provided any information on how the tables are related to each
other. There are several examples in Books Online.

Jul 20 '05 #2
On Sat, 02 Oct 2004 13:20:47 +0100,
rc@die@you@!spammers.sandworm.demon.co.uk wrote:
Hi

I am kind of new to sql, so here goes my question

I have this sql update query

update [CACI-table] set premeses=[xaa].[Sub Building]
where (premeses is null)

Waht is wrong with this.

I have tow table called xaa and CACI-table and all I want to do is
take one column from one table and and put itto the other

Query analysider says the following err message

The column prefix 'xaa' does not match with a table name or alias name
used in the query.


Hi rc,

You have to tell SQL Server from what row in the xaa table it should take
the Sub Building. The easiest way to do this, in your situation, is by
using a subquery. Something like this:

UPDATE [CACI-table]
SET premeses = (SELECT [Sub Building]
FROM [xaa]
WHERE [xaa].[Some column] = [CACI-table].[Some column]
AND ....
)

The WHERE clause of the subquery can be simple or complex. It probably
should refer in some way to columns in the table to be updated (assuming
that the "correct" row in xaa is different for each row in CACI-table) and
it should return exactly one row for each row in CACI-table. You'll get an
error if it returns more than one row; if it returns no rows, the value of
premeses in the corresponding CACI-table row will be set to NULL.

If you have trouble getting this right, post again but provide a little
more detail, like:
* Structure of your tables (as CREATE TABLE statements, including all
constraints - see http://www.aspfaq.com/etiquette.asp?id=5006).
* Sample data that shows what you want to achieve (as INSERT statements,
see http://vyaskn.tripod.com/code.htm#inserts).
* Expected output for the sample data provided.
* A concise description of the business problem you want to solve.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #3
rc
Thanks, I understand now

Thanks again
Hi

I am kind of new to sql, so here goes my question

I have this sql update query

update [CACI-table] set premeses=[xaa].[Sub Building]
where (premeses is null)

Waht is wrong with this.

I have tow table called xaa and CACI-table and all I want to do is
take one column from one table and and put itto the other

Query analysider says the following err message

The column prefix 'xaa' does not match with a table name or alias name
used in the query.


Hi rc,

You have to tell SQL Server from what row in the xaa table it should take
the Sub Building. The easiest way to do this, in your situation, is by
using a subquery. Something like this:

UPDATE [CACI-table]
SET premeses = (SELECT [Sub Building]
FROM [xaa]
WHERE [xaa].[Some column] = [CACI-table].[Some column]
AND ....
)

The WHERE clause of the subquery can be simple or complex. It probably
should refer in some way to columns in the table to be updated (assuming
that the "correct" row in xaa is different for each row in CACI-table) and
it should return exactly one row for each row in CACI-table. You'll get an
error if it returns more than one row; if it returns no rows, the value of
premeses in the corresponding CACI-table row will be set to NULL.

If you have trouble getting this right, post again but provide a little
more detail, like:
* Structure of your tables (as CREATE TABLE statements, including all
constraints - see http://www.aspfaq.com/etiquette.asp?id=5006).
* Sample data that shows what you want to achieve (as INSERT statements,
see http://vyaskn.tripod.com/code.htm#inserts).
* Expected output for the sample data provided.
* A concise description of the business problem you want to solve.

Best, Hugo


Jul 20 '05 #4
Search for a copy of one of my standard "cut & paste" descriptions of
how an UPDATE works. If I post it again, the regulars will scream.
Adam also has an old posting showing why you never, never use
proprietary UPDATE.. FROM .. syntax.

--CELKO--
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are. Sample data is also a good idea, along with clear
specifications.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rc | last post by:
Hi You can do a select top 1 * from <table>, my question is how does one delete the row whithout having to do lots of where clause ? Is there a equivelant delete top 1 from <table> Thanks
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
1
by: galsaba | last post by:
1. I want to have the value 01 if the number is 1 waht would be the function? 2. i think i need to use the function formatnumber. Where can I find on the web the syntex of cstr( ,...
1
by: Nikhil Patel | last post by:
Hi all, I have the following code in the asp.net page added at runtime using RegisterStartupScript. But I get an error in the browser(syntex error-no details). DisplayLookupValues is a function...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
5
by: Leanne | last post by:
I am doing customization for Microsoft Pos. I am working on installation package now. I added some new tables and stored procuedures and generated SQL Script for that. During the installation...
12
by: si_owen | last post by:
Hi all, I have a SQL query that worked fine in my project until it came to testing. I found that the NvarChar fields I have wont accept the use of an ' My code and query is here does anyone...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.