Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert into query one field?

Status
Not open for further replies.

Cosmiccradle

Technical User
Mar 24, 2003
63
NL
Is there anyone that can help with the following: using the "insert into" query only gives me one field at a time.

INSERT INTO Kleinebibliotheken ( Filiaal, Code, Titel, Siso, Prijs, Jgd, Vlw, Opmerking, Basislijstnr )
SELECT 'Betondorp' AS Filiaal, 'w' AS Code, 'Try Again' AS Titel, '422.22' AS Siso, ' 45,00' AS Prijs, 'P' AS Jgd, ' ' AS Vlw, 'ipv Bobbo' AS Opmerking, '1 ' AS Basislijstnr;

What I need is that the SELECT expression can fill more then 9 fields at a time instead of one as in Betondorp, which is one of nine branch libraries.

Tanks for any help Cosmiccradle
 
Insert from where? If you have only values to insert, use the VALUES word:

INSERT INTO Kleinebibliotheken ( Filiaal, Code, Titel, Siso, Prijs, Jgd, Vlw, Opmerking, Basislijstnr )
VALUES ('Betondorp', 'w', 'Try Again', '422.22', ' 45,00', 'P', ' ', 'ipv Bobbo', '1 ');

Good luck

[pipe]
Daniel Vlas
Systems Consultant
 
Daniel thanks for answering, Kleinebibliotheken has nine branch libraries, the one value Betondorp is just one of the libraries. I need to add all values after Betondorp to the rest of the libraries.

Cosmiccradle
 
Then you need an UPDATE query:

Update Kleinebibliotheken Set Code = &quot;w&quot;, Titel = &quot;Try Again&quot;, Siso = &quot;422.22&quot;, Prijs = &quot;45,00&quot;, Jgd=&quot;P&quot;, Vlw = &quot; &quot;, Opmerking = &quot;ipv Bobbo&quot;, Basislijstnr = &quot;1&quot; Where Filiaal <> &quot;Betondorp&quot;;

HTH,


[pipe]
Daniel Vlas
Systems Consultant
 
Hi again:

I guess the problems lies with me, because maybe I'm not making myself clear. I have nine branch libraries under the field heading Filiaal under each of these libraries i need to add a new title, Siso (book number), Prijs(cost), wether it is a book for children or adults (Jgd/Vlw) and if the are any Comments(Opmerking) and the Basislist to which the library needs(Basislijstnr). The only thing that I need is that all libraries are atachted to the other fields like Siso,prijs ect. In this case Filiaal should be Betondorp+ Geuzenveld+Buitenveldert ect. the rest stays the same. I have tried your last solution but it repeats itself 340 times, I only need that each of the nine libraries recieve the new titel and other information once. I believe that Update is used to change an already exsisting Titel. Thankyou for your help and patience. Remember Dutch is my language and not english that's why it's difficult for me to perhaps write down excactly what I mean.

Cosmiccradle Thankyou
 
How is your database structured? What tables do you have and what are the relationships between them?
Where do you store the titles and how do you know they have not already been assigned to the branches?

A picture says more than 1000 words...


Have I completely missed the point?

[pipe]
Daniel Vlas
Systems Consultant
 
I'll be going home soon but to give you a short example:
translated in English

The table name is SmallBranchlibraries
The Collum Names are as follows
I'll use short forms

ID/Library/Code/Title/Booknr/Cost/Youth/Adult/Comment/Basis
1 /Bet /w / a /422 /45 / p / / start/ 1
2 /Gue /w / a /422 /45 / p / / start/ 1

What I want to do is the following with the Insert Into query

3 /Bet /w / B /453 /50 / p / /up /1
4 /Gue /w / B /453 /50 / p / /up /1

In one way or another I need to have one place where I can tell the table that he needs to add the Title with information to the nine different libraries such as Bet and Gue. I hope this clears it up.

Thanks Cosmiccradle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top