>>INSERT INTO Printer
SELECT model FROM Product WHERE EXISTS ( select 1 from product where model = <user input> )
that's how user input is defined in mysql?
Main Topics
Browse All TopicsHey,
As my question describes, I'm trying to find a way to check if a value existed in one table, and then insert into another. I'm kinda stuck on what to call user input... nothing explains that. This is what I have so far:
SELECT model FROM Product WHERE IF EXISTS <user input> INSERT INTO Printer;
I really really need help on this.
Thanks in advance!!!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Are you using MySQL or SQL 2008? You better clarify beacause syntax is different.
Anyway these are both database platforms. They have no capability for 'user input'. You can type a query in and run it but there is nothing nice to accept user input and run a query.
You need some kind of a front end developed on the web/MS Access/Win Forms etc.
I'm not too familiar with MySQL.
To insert stuff you type an INSERT query into the database client tool and run it. If you are happy for your users to do that, go ahead.
Or you connect to the database within an application and run an insert query from there. Your application may also include a nice form that asks for user input and then builds an insert statement and runs it. You can also use an 'API' which means you don't need to build an actual INSERT query, you do it more programatically.
Your question is bit unclear yet.
>> SELECT model FROM Product WHERE IF EXISTS <user input> INSERT INTO Printer;
Do you want to insert in to 'printer' table from 'product' table only if <user input> value exists in 'product table'?
>> As query suggested by aneeshattingal copies data from Product table to Printer table.
Do you want to insert the same data from product table or new data to printer table?
The same thing can be written as
INSERT INTO Printer SELECT model FROM Product WHERE model = <user input>;
>> What exactly you're trying to do?
>> Check below mentioned link if it's of any use to you, esp. ON DUPLICATE KEY UPDATE section:
http://dev.mysql.com/doc/r
Business Accounts
Answer for Membership
by: aneeshattingalPosted on 2009-11-02 at 20:47:43ID: 25726124
INSERT INTO Printer
SELECT model FROM Product WHERE EXISTS ( select 1 from product where model = <user input> )