3 Replies - 5621 Views - Last Post: 16 June 2008 - 01:17 PM

#1 linuxunil  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 46
  • Joined: 07-March 06

[Access] Inserting single value into multiple rows

Posted 16 June 2008 - 12:16 PM

I need to insert a value (say Blue) into and existing table. But I only need to do it to certain existing rows with a range of values in one column ( say 399 - 500) , and a certain column. The value I'm inserting doesn't change. I tried
 INSERT INTO table (column2) VALUES ('Blue') SELECT column1 FROM table WHERE column1 < 500 AND > 399;
but this just gives errors in access. The other lady working on this project has had a SQL class but has had no luck remembering enough to do this.

Any help would be greatly appriciated, even links.

Note: I am not a SQL developer, nor do I use SQL much at all. This is for a project at my Internship.

This post has been edited by linuxunil: 16 June 2008 - 12:17 PM


Is This A Good Question/Topic? 0
  • +

Replies To: [Access] Inserting single value into multiple rows

#2 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: [Access] Inserting single value into multiple rows

Posted 16 June 2008 - 12:32 PM

I think you are looking for the update command.
Was This Post Helpful? 1

#3 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 294
  • View blog
  • Posts: 1,533
  • Joined: 07-April 08

Re: [Access] Inserting single value into multiple rows

Posted 16 June 2008 - 12:35 PM

View Postlinuxunil, on 16 Jun, 2008 - 12:16 PM, said:

I need to insert a value (say Blue) into and existing table. But I only need to do it to certain existing rows with a range of values in one column ( say 399 - 500) , and a certain column. The value I'm inserting doesn't change. I tried
 INSERT INTO table (column2) VALUES ('Blue') SELECT column1 FROM table WHERE column1 < 500 AND > 399;
but this just gives errors in access. The other lady working on this project has had a SQL class but has had no luck remembering enough to do this.

Any help would be greatly appreciated, even links.

Note: I am not a SQL developer, nor do I use SQL much at all. This is for a project at my Internship.



your Syntax is wrong. What i'm assuming is you want to enter into column 2 the value of blue where the rownum is between 399 and 500

and i'm assuming column1 is defined as numeric.


  

INSERT INTO table (column2) VALUES ('Blue') //This basically adds the Value of blue to column2 in table named table

SELECT column1 FROM table WHERE column1 <500 AND >399;  // this is unknown because there is nothing to add this too.  



try this:


UPDATE table SET column2 = 'Blue'  WHERE column1 BETWEEN 399 AND 500;





not sure if the keyword BETWEEN works in access but if it doesnt do this


UPDATE table SET column2 = 'Blue' WHERE column1 > 399 AND column1 < 500;



Was This Post Helpful? 1
  • +
  • -

#4 linuxunil  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 46
  • Joined: 07-March 06

Re: [Access] Inserting single value into multiple rows

Posted 16 June 2008 - 01:17 PM

Thank you rgfirefly24 that worked perfectly. And we found out the lady helping me had that just not in the right order :D .
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1