Hi Mark
People_id is the column with auto increment? You can verify that it
really does have auto_increment by using the "describe" command. For
example:
mysql> describe checks;
+-----------------+------------------+------+-----+---------
+----------------+
| Field | Type | Null | Key | Default |
Extra |
+-----------------+------------------+------+-----+---------
+----------------+
| id | int(14) unsigned | NO | PRI | |
auto_increment |
| original_check | int(14) unsigned | YES | |
| |
| hotel_pos | int(7) | YES | |
| |
| number | int(5) unsigned | YES | |
| |
| revenuecenter | int(9) unsigned | YES | MUL |
| |
| open_time | datetime | YES | MUL |
| |
| close_time | datetime | YES | |
| |
| employee | int(8) unsigned | YES | MUL |
| |
| cashier | int(8) unsigned | YES | |
| |
| restauranttable | int(3) unsigned | YES | |
| |
| covers | int(4) | YES | |
| |
+-----------------+------------------+------+-----+---------
+----------------+
11 rows in set (0.15 sec)
If that's set up correctly, you should be able to leave that column
out of the list, e.g.
$people = "INSERT INTO people (people_full_name, people_isactor,
people_isdirector) VALUES ( 'Jim Carey', 1, 0), (2, 'Tom Shadyac',
0, 1), ( 'Lawrence Kasdan', 0, 1), ( 'Kevin Kline', 1, 0), ( 'Ron
Livingston', 1, 0), ('Mike Judge', 0, 1)";
$results = mysql_query($people) or die(mysql_error());
Thus I could insert into the table I describe above as:
mysql> insert into checks (original_check, hotel_pos, number) values
(123, 1, 456), (124, 1, 456), (125, 1, 443);
Query OK, 3 rows affected (0.11 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select count(*) from checks;
+----------+
| count(*) |
+----------+
| 5542 |
+----------+
1 row in set (0.04 sec)
mysql> select * from checks limit 5539, 3;
+------+----------------+-----------+--------+---------------
+-----------+------------+----------+---------+-----------------
+--------+
| id | original_check | hotel_pos | number | revenuecenter |
open_time | close_time | employee | cashier | restauranttable | covers |
+------+----------------+-----------+--------+---------------
+-----------+------------+----------+---------+-----------------
+--------+
| 5540 | 123 | 1 | 456 | NULL
| | | NULL | NULL | NULL |
NULL |
| 5541 | 124 | 1 | 456 | NULL
| | | NULL | NULL | NULL |
NULL |
| 5542 | 125 | 1 | 443 | NULL
| | | NULL | NULL | NULL |
NULL |
+------+----------------+-----------+--------+---------------
+-----------+------------+----------+---------+-----------------
+--------+
3 rows in set (0.01 sec)
Douglas Sims
[EMAIL PROTECTED]
On Jun 1, 2006, at 4:12 AM, Mark Sargent wrote:
Hi All,
if a table has an auto_incremented primary key why does the below
code require the people_id to be manually inserted? I got this from
Beginning PHP, Apache, MySQL Web Development book from Wrox.
Curious, as it seems to defeat the purpose of auto_increment, no?
Cheers.
$people = "INSERT INTO people (people_id, people_full_name,
people_isactor, people_isdirector) VALUES (1, 'Jim Carey', 1, 0),
(2, 'Tom Shadyac', 0, 1), (3, 'Lawrence Kasdan', 0, 1), (4, 'Kevin
Kline', 1, 0), (5, 'Ron Livingston', 1, 0), (6, 'Mike Judge', 0, 1)";
$results = mysql_query($people) or die(mysql_error());
Mark Sargent
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]