944,001 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 1613
  • MySQL RSS
Mar 8th, 2006
0

Question about inserts

Expand Post »
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:
MySQL Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
hinde is offline Offline
60 posts
since Jul 2005
Mar 9th, 2006
0

Re: Question about inserts

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.
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: HELP! MySQL with phpMyAdmin 2.5.5-p\1
Next Thread in MySQL Forum Timeline: Query Cache





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC