Posts Under mysql Category
LEN in MySQL
In MySQL 5.1 LEN is called LENGTH, you use it exactly the same and pass in the link, so: LENGTH(link).
SELECT Duplicate Items Using SQL
If you have a table which has duplicate items in then you can use the below statement to select them. SELECT * FROM tableName GROUP BY columnName HAVING ( COUNT( columnName) >1 )
MySQL Error: Can’t get hostname for your address
This error is thrown by MySQL because it tries to do a DNS lookup on the address connecting to the server and it fails due to the IP not being able to be resolved back to a name or some-other deeper DNS bust problem. The easiest way to fix this is to edit your my.ini or my.cnf (/etc/my.cnf) and in the [mysqld] section add the “skip-name-resolve” option. Near the top…
2014 – Commands out of sync; you can't run this command now
#2014 – Commands out of sync; you can’t run this command now Now that can be a really annoying error! It happens when querying stored procedures in phpMyAdmin as mysqli seems to return 2 sets of results opposed to the usual 1 that mysql returns. You cannot call anything else until you have “flushed” or “cleared” the second result. You can try using COMMIT to resolve this.
MySQL Main Query Types used in PHP to select, insert, update and delete data
MySQL Main Query Types SELECT SELECT * FROM tablename INSERT INSERT INTO tablename (col1, col2, col3,..) VALUES (val1, val2, val3,…) UPDATE UPDATE tablename SET `col1`=`val1`, `col2`=`val2`, `col3`=`val3`,… DELETE DELETE FROM tablename WHERE `col4`=`val6` Note You will use a lot of WHERE clauses as well along with the above. e.g. SELECT * FROM tablename WHERE `id`=’15′ In PHP Calling to MySQL is really easy in PHP, just use the mysql_query() function….
Connect to mysql database from php
If you need to connect to a mysql database from php you can do it like this: <?php> $DBH = ‘localhost’; $DBU = ‘root’; $DBPWD = ‘password’; $DBN = ‘petstore’; $conn = mysql_connect($DBH, $DBU, $DBPWD) or die ("Error: Could not connect to database."); mysql_select_db($dbname); ?> This allows you to make a connection to the mysql database and gets it ready for you to make…
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource You have just gotten a warning when trying to check if an inserted row was successful but when calling mysql_affected_rows(mysql_query(“INSERT INTO……”)) you get a warning telling you that the supplied argument is not a valid MySQL-Link resource. This is because mysql_query INSERT actually returns true or false and not a resource id. So rather do this: if (mysql_query(“INSERT INTO…”))
mySQL select multiple ids
SELECT * FROM tablename WHERE `active`=’1′ AND `id` IN (’107′ , ’125′ ) ORDER BY `id` DESC LIMIT 12
mySQL Development Tools
I came across a very interesting article about mySQL Development Tools. http://www.smashingmagazine.com/2009/03/25/mysql-admin-and-development-tools-round-up/