|
Select Statement List of Categories
Page 1 Page 2
- How do I select records that have a null value?
- How do I select the last record inserted into a table?
- How to I count the number of records in a MySQL table?
-
How do I select records that have a null value?
Often records will contain no value at all becuase when the column was added or the table was created, it was not defined as NOT NULL. Selecting these records would be almost impossible without the isNull function:
SELECT * FROM tablename WHERE ISNULL(columnname)
-
How do I select the last record inserted into a table?
This depends on the the version of MySQL your server is running. You could try the LAST_INSERT_ID() function :
SELECT LAST_INSERT_ID() FROM tablename
Or if that fails, try using insertid on the execute insert command.
$VAR{x} = $DB->query('INSERT INTO tablename SET id = 1');
$VAR{i} = $VAR{x}->insertid;
-
How to I count the number of records in a MySQL table?
SELECT COUNT(columnname) FROM tablename
Page 1 Page 2
|
|
|