PDA

View Full Version : Query Help - Just a question about writing a query...


Rose
03-12-2003, 04:03 PM
I'm praciticing some queries and I have a couple questions. First, let me explain my practice queries -

I figured I'd just write a bunch of "INSERT INTO"'s for different calendar events (general holiday stuff).


INSERT INTO calendar_events (eventid, userid, event, eventdate, public, subject, allowsmilies) VALUES (4, 1, 'Thanksgiving - US.\r\n\r\n\r\n', '2003-11-27', 1, 'Thanksgiving', 1);



My question is this - Must I set the eventid, or is there a way to have it automatically set itself. Reason being - I have events already added to the calendar and I just wondered if I needed to consecutively add all the eventid's appropriately or if it could do it magically itself.

Xenon
03-12-2003, 04:24 PM
look into the field properties, if the field has the autoincrement enabled you can just set NULL as id and it'll use the highest free id ;)

Rose
03-12-2003, 04:32 PM
Originally posted by Xenon
look into the field properties, if the field has the autoincrement enabled you can just set NULL as id and it'll use the highest free id ;)


I believe it has autoincrement enabled for the eventid. Yes.

*test*

Sweeet! Thanks, Xenon. It worked like a charm.

* Rose takes note in lil' fat cheatsheet book and chalks another learning point up

*hehe*

Serge
03-13-2003, 01:11 AM
Ok just another question that would build on this one. When I wanted to query for that information to echo it out for whatever and I set up a query somewhat like this:


$results = mysql_query("select * from table")


Also if I didn't want everything would I just take out the star and insert the fields I wanted. And what would be the sentax if I only wanted say the username and password from the table.

Sorry for the all questions I'm just very interested. :)

mr e
03-13-2003, 02:14 AM
$results = mysql_query("SELECT username, password FROM table");


btw, whats up with the quote boxes?