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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL SELECT all but Primary key column?

Status
Not open for further replies.

Mermogoat

Programmer
Nov 1, 2003
2
US
Is there a way to SELECT all data from all columns, and exclude the entire primary key column? I have searched the documentation, but cannot find anything. Thanks
 
select <field1>,<field2> from tablename;
you need to explicitly specify the columns leaving out the primary key field
 
Well, I'm making a generic insert_row function for my web application, and I'm dynamically creating the fields to enter data, however, I don't want them to enter a value for the id field since's it is an auto-increment primary key.
 

i believe in mysql you can insert NULL into an auto_increment field and it will get the next number the same as if you had omitted it from the INSERT statement

test it first before relying on this info, eh


rudy
 
What about submitting an explain or desc query like this

explain unknowntable;

then read the results which are a description of all of the fileds inculding whether they are a primary key

 
If you use form elements that bring the values you want to insert then you can look at

thread436-681336 I have automated my inserts and update statements





 
u can insert implicit NULL i.e if table tst2 has 2 cols no (integer, primry, Auto_increment) and
form (integer)then
Code:
insert into tst2 (form) values(1)
would add insert value in filed &quot;no&quot;




[ponder]
----------------
ur feedback is a very welcome desire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top