Question about inserts

Reply

Join Date: Jul 2005
Posts: 60
Reputation: hinde is an unknown quantity at this point 
Solved Threads: 4
hinde hinde is offline Offline
Junior Poster in Training

Question about inserts

 
0
  #1
Mar 8th, 2006
I am writing from the ground up a feature for this one company in Georgia while I am in school. It is running on mysql, but I have encountered a problem (actually a few problems, which led to this problem). I use auto increment for the unique identifiers for each of my tables. Now when I insert into a table, all the examples of inserts tell me to type out all of my column names. This would not bother me so much if I could use stored procedures (my boss does not feel they are enterprise ready yet, and I would have to say that I agree with him). Since I cannot use stored procedures, I am writing the scripts in php in an include file and have php query the database, not a stored procedure. In terms of securing the data model (which I would have to say I am very proud of), this is not a good idea. Should anyone get a hold of the php code, they could easily figure out my entire data model, just not the primary keys.

Is there a way to insert into a table while skipping over a particular column without having to type out all the column names? For instance:
  1. INSERT INTO table1 VALUES (id, info1, info2, info3); /* indiscriminate insert */
  2. INSERT INTO table1 (column2, column3, column4) VALUES (info1, info2, info3); /* insert I have now */
  3. INSERT INTO table1 (all but column1) VALUES (info1, info2, info3); /* insert I want */

Any help would be appreciated.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Question about inserts

 
0
  #2
Mar 9th, 2006
I've looked into this "issue" myself a few times. First, I've been doing this long enough to vouch that you really do want to specificy exact columns. I only use '*' in my quick & dirty test code.

To my knowledge there is not any way to do exactly what you describe.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC