473,386 Members | 1,821 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 - Help!!

94
When performing the following update:
UPDATE learner_ilr l
SET l.prior_attain_level =
(SELECT p.prior_attain_level
FROM people p
WHERE p.person_code = l.person_code
AND p.prior_attain_level IS NOT NULL)
WHERE
l.prior_attain_level IS NULL AND
l.funding_year = 13
the section in bold is being ignored. Is there a logical reason why this might be happening? Have i written the update incorrectly?
Oct 2 '07 #1
5 1083
ck9663
2,878 Expert 2GB
When performing the following update:
UPDATE learner_ilr l
SET l.prior_attain_level =
(SELECT p.prior_attain_level
FROM people p
WHERE p.person_code = l.person_code
AND p.prior_attain_level IS NOT NULL)
WHERE
l.prior_attain_level IS NULL AND
l.funding_year = 13
the section in bold is being ignored. Is there a logical reason why this might be happening? Have i written the update incorrectly?
try:


Expand|Select|Wrap|Line Numbers
  1.     UPDATE learner_ilr l
  2.     SET l.prior_attain_level = 
  3.     FROM people p INNER JOIN  p.person_code = l.person_code 
  4.     WHERE
  5.     p.prior_attain_level IS NOT NULL
  6.     AND
  7.     l.prior_attain_level IS NULL AND
  8.     l.funding_year = 13
Oct 2 '07 #2
Lewe22
94
That doesn't work, error 'missing expression' at FROM.

I've spent a long time trying to figure this out and in particular it is the position of the FROM that i can't get to work.

Created in Access the structure of the query works like:
UPDATE table1 INNER JOIN table2
ON table1.field1 = table2.field2
SET table1.fieldx = table2.fieldn
WHERE conditions...
The same structure does not work as a SQL pass through query though and i don't really understand where to declare table2 (people) peoperly.
At the moment i am declaring it in the sub query but realise it needs to be declared somewhere in the main update. HELP!!
UPDATE learner_ilr l
SET l.prior_attain_level =
(SELECT p.prior_attain_level
FROM people p
WHERE p.person_code = l.person_code
AND p.prior_attain_level IS NOT NULL)
WHERE
l.prior_attain_level IS NULL AND
l.funding_year = 13
Oct 3 '07 #3
ck9663
2,878 Expert 2GB
try:


Expand|Select|Wrap|Line Numbers
  1.     UPDATE learner_ilr l
  2.     SET l.prior_attain_level = 
  3.     FROM people p INNER JOIN  p.person_code = l.person_code 
  4.     WHERE
  5.     p.prior_attain_level IS NOT NULL
  6.     AND
  7.     l.prior_attain_level IS NULL AND
  8.     l.funding_year = 13
let's do that again....

Expand|Select|Wrap|Line Numbers
  1.       UPDATE learner_ilr l
  2.           SET l.prior_attain_level = p.prior_attain_level
  3.           FROM people p INNER JOIN  p.person_code = l.person_code
  4.           WHERE
  5.           p.prior_attain_level IS NOT NULL
  6.           AND
  7.           l.prior_attain_level IS NULL AND
  8.           l.funding_year = 13
--CK
Oct 3 '07 #4
Lewe22
94
I did try that but it still didn't work! Same error message!
Oct 4 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
I did try that but it still didn't work! Same error message!
i think what ck9663 meant was
Expand|Select|Wrap|Line Numbers
  1. UPDATE learner_ilr l
  2.           SET l.prior_attain_level =(select p.prior_attain_level
  3.           FROM people p INNER JOIN  p.person_code = l.person_code
  4.           WHERE
  5.           p.prior_attain_level IS NOT NULL
  6.           AND
  7.           l.prior_attain_level IS NULL AND
  8.           l.funding_year = 13)
Please try to correct the code youself.

cheers
Oct 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Paul Eden | last post by:
Hello all. I'm totally stumped. Please de-stump me! I've read my data in from the database, changed it according to what i want to do and now I want to write it back. But it seems I can only...
1
by: MattMika | last post by:
I am trying to integrate a Credit Card # deletion option into Batch_print_center and need some help. Batch_print_center has a form where you specify orders you want to print or proccess by...
8
by: Jason | last post by:
I have a table that matches up Securities and Exchanges. Individual securities can belong on multiple exchanges. One of the columns, named PrimaryExchangeFlag, indicates if a particular exchange is...
7
by: Steve B. | last post by:
Does anyone know why the DA Update() would throw an exception? I moved the database but I updated the Conn and the DA, currently (trying)removing/replacing DS. Is there a another direction I...
0
by: Ash | last post by:
Hi, I'm using Vb.NET webform, connecting to sql server database on the local machine. I used datagrid propery builder to add the edit, update and cancel colum. On the code, i have: Private...
4
by: Mike | last post by:
I have an update page and on the page there are sometimes names with 's (car's) in it When I try to update it i get a syntax error. How can i update the record with a 's (car's) in the name? thx
2
by: billr | last post by:
SQL newby in deep water thats way over my head. Any help appreciated. I am trying to retrieve data from field in one table and append it to on field in a second table. Each the fields had a Field ID...
0
by: Mangler | last post by:
I have a form that does multiple updates on the page. For some reason that I cant figure out it is redirecting before the update is done. It doesnt do this on another page that I have. <% If...
7
by: wizardry | last post by:
i can query the list fine using: select list.list, many_table.list_id_fk from list left join many_table on list.id = many_table.list_id_fk and many_table.userid = 'UserId'; that populates...
1
by: donken | last post by:
Hi I'm trying to update changes made in a dataset to an existing .dbf file. But I can't figure it out. I connect to the file via ODBC connection and the updates to the DataSet works fine but then...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.