$sql = “SELECT * FROM tbl”; $result = mysql_query($sql); if (mysql_num_rows($result)==0) { //do this } else { //do that }
Category: Database
To Copy a single table in a Schema into another existing Schema CREATE TABLE myschema.mytbl LIKE myschema2.mytbl; INSERT INTO myschema.mytbl SELECT * FROM myschema2.mytbl; To Copy all the tables in a Schema into another existing Schema In cmd/terminal, dump the database mysqldump -u root -ppass myschema > /path/to/myschema.sql In cmd/terminal, use the new database […]
Create New MySQl User with Privileges GRANT ALL PRIVILEGES ON dbTest.* To ‘user’@’hostname’ IDENTIFIED BY ‘password’; So for example: Log in to Mysql… mysql -u [root] -p Then type: GRANT ALL PRIVILEGES ON [schema]. To ‘[user]’@'[hostname]’ IDENTIFIED BY ‘[password]’; How to View Current Users and Privileges SHOW GRANTS; or select user,host from mysql.user;
MySQL Insert If Not Exists Why doesn’t MySQL Insert If Not exists work????? UPDATE: CHECK AT THE BOTTOM OF POST Bogdan has the answers . First of all, this information relates solely to MySQL and may not apply to MSSQL or PostgreSQL. Have you been trying to insert records into a table based on whether there […]