Question:
ALTER TABLE - MYSQL QUERY HELP?
anonymous
2010-12-31 12:26:03 UTC
Im trying to use the alter table function in mysql but I dont know if I am doing it right...

[php]mysql_query("INSERT INTO prueba (`ID`, `NAME`, `DESCRIPTION`)
VALUES (NULL,'$name','$desc')") or die(mysql_error());

mysql_query(" ALTER TABLE prueba AUTO_INCREMENT = 1
VALUES (NULL,'$name','$desc')") or die(mysql_error()); [/php]

Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES (NULL,'ljnlkj','lkjh')' at line 2

help...
Five answers:
TheMadProfessor
2011-01-03 08:28:55 UTC
As the others mention, your ALTER TABLE statement really doesn't make sense...looks more like a UPDATE statement. Either that's more what you intended or you need to describe exactly what you're trying to do here.
anonymous
2010-12-31 13:02:13 UTC
And you can't insert into an autoincrement field:



INSERT INTO prueba (`NAME`, `DESCRIPTION`) VALUES ('$name','$desc')
Abrar Alam
2010-12-31 12:49:03 UTC
your 2nd line query is wrong ,,,,, ALTER TABLE is a using the alter diffinition of table,,,



what u want to alter ,,,,,, you can prefer google,,,,,

thanx
?
2010-12-31 12:37:57 UTC
A Values() clause is used with Insert Into, but not Alter Table. Looks like a copy/paste error. Look up the Alter Table syntax in a MySql reference.
?
2016-10-27 07:10:54 UTC
[EDIT] Wow i did not study about FULLTEXT -- that is a miles extra stylish (and positively extra powerful) answer to this project. [/end EDIT] Assuming what you want is to locate all rows the position each and every of the most words the consumer enters would nicely be found in a unique column, you should use this: opt for field1, field2, field3 FROM table_name the position (field1 LIKE '%apple%' AND field1 LIKE '%toast%') for sure you'll likely favor to strengthen in this -- as an social gathering that's case smooth. in case you do not favor it to be case smooth replace: field1 LIKE '%apple%' to: top(field1) LIKE top('%apple%' ) (etc) you could also do all styles of issues with ANDs and ORs and whanot.. as an social gathering all rows with "apple" and "toast" in them OR "jam" and "butter" yet not cranberry ... the position ( ( (top(field1) LIKE '%APPLE%' AND top(field1) LIKE '%TOAST%') OR (top(field1) LIKE '%JAM%' AND top(field1) LIKE '%BUTTER%') ) AND top(field1) unlike '%CRANBERRY%' )


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...