Click to See Complete Forum and Search --> : sql code..


computerpro
01-31-2006, 08:52 PM
Well iam coding a search engine in php and would like some help using mysql databasing.

So far I have:

$query = "SELECT * FROM tbl WHERE (column LIKE '%".$v."%' OR column LIKE '".$v."%' OR column LIKE '%".$v."')";
// $v is what they want to search for


How does one insert information in a column etc.

Thanks!

chazzy
01-31-2006, 09:36 PM
you insert using the insert command.

typically it's INSERT into table_name(column_list) VALUES(value_list);
and mysql has an added feature (that NogDog pointed out to me) that you can do:
INSERT INTO table set column1=value1, column2=value2, ...
but don't do it that way.

just so you know:

(column LIKE '%".$v."%' OR column LIKE '".$v."%' OR column LIKE '%".$v."')"


reduces to

(column LIKE '%".$v."%')


reason: % is replaced by any number of characters, 0-n.

computerpro
02-01-2006, 05:49 PM
Thanks but how do I add a column into a mysql db (I know how to add a table)

chazzy
02-02-2006, 09:07 AM
see here, very clear explanation:

http://dev.mysql.com/doc/refman/4.1/en/alter-table.html