Changing a field in mysql using mysql cmd line - mysql

I'm trying to get more familiar with using command line.. so i'm kind of new.
How would i update this field 'value' from 1 to 0?
mysql> SELECT * FROM core_config_data WHERE path = 'web/seo/use_rewrites'
-> ;
+-----------+---------+----------+----------------------+-------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+----------------------+-------+
| 18 | default | 0 | web/seo/use_rewrites | 1 |
+-----------+---------+----------+----------------------+-------+
1 row in set (0.01 sec)
I tried this update statement but it didn't work:
UPDATE core_config_data SET value='0' WHERE config_id=18;
I threw this error in command line:
ERROR 1064 (42000): 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 'WHEREc WHERE config_id=18' at line 1

Related

While I am trying to updating a row to my table, I'm getting the following errors:

mysql> select * from GSLAB;
+--------+--------------+
| empid | destignation |
+--------+--------------+
| GS101 | Manager |
| GS102 | ABC |
| GS-103 | SAS |
| GS-104 | dsSAS |
| GS105 | EWSAS |
| GS106 | EWQAS |
+--------+--------------+
6 rows in set (0.00 sec)
mysql> update GSLAB set empid= substr(empid,4,15)||substr(empid,1,2)||'-' where empid substr(empid,1,3)<>'-';
ERROR 1064 (42000): 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 'substr(empid,1,3)<>'-'' at line 1
mysql>
I use concat function instead of concat operator '||'
mysql> update GSLAB set empid= concat(substr(empid,1,2),'-',substr(empid,4,15)) where substr(empid,1,3)<>'-';

Unable to update a table due to ERROR 1064 (42000)

I did realized that there have been concern raised regrading this error but this one quite different. I have a table below and unable to update it due to ERROR 1064.
Please help
mysql> desc propertystring;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| ID | decimal(18,0) | NO | PRI | NULL | |
| propertyvalue | text | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
UPDATE propertystring SET propertyvalue = 'x.x.x.x/jira' FROM propertyentry PE WHERE PE.id=propertystring.id and PE.property_key = 'jira.baseurl';
ERROR 1064 (42000): 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 'FROM propertyentry PE WHERE
PE.id=propertystring.id and PE.property_key = 'jira.' at line 1
Have tried different quotes but cannot update the feild. is it because field type is "text" ?
Thanks guys for the hint. #John Conde you are right the correct way to do this is as below without FROM clause UPDATE propertystring PS JOIN propertyentry PE ON PE.id=PS.id and PE.property_key = 'jira.baseurl' SET PS.propertyvalue = 'x.x.x.x/jira';

why does mysql say I have an error in my SQL syntax, when I use the command help and status?

mysql> help;
1064 - 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 '' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cppp |
| db_byb_develop |
| mysql |
| test |
| train |
+--------------------+
6 rows in set
mysql> status
-> ;
1064 - 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 'status' at line 1
Its
SHOW STATUS;
not just
status ;
https://dev.mysql.com/doc/refman/5.0/en/show-status.html

database name in mysql seems valid but it is showing an error

I am trying to create a database with a '-' in between two words and it should work perfectly fine but it isn't. here is the log file:
mysql> create database test1;
Query OK, 1 row affected (0.00 sec)
mysql> show databases
-> ;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| mifos |
| mifosplatform_tenants |
| mifostenant |
| mifostenant_default |
| mysql |
| performance_schema |
| sakila |
| test |
| test1 |
| testing |
| world |
+-----------------------+
12 rows in set (0.00 sec)
mysql> create database test1-mohit;
ERROR 1064 (42000): 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 '-mohi
t' at line 1
you can use _(underscore)
create database test1_mohit;
or try this
create database `test1_mohit`;
These both will work
Use one of these character for naming database [0-9,a-z,A-Z$_]
Reference: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

How to DROP a database with character '?' in its name?

Just trying out ubuntu server on my pc and have been testing some commands including mysql. I'm not sure why phpMyAdmin permitted me to create a database like this 'testing?db'. I'm trying to drop this database via SSH but I get this error:
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| phpmyadmin |
| testing?db |
| testing_db |
| wp |
+--------------------+
6 rows in set (0.00 sec)
mysql> DROP DATABASE testing?db;
ERROR 1064 (42000): 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 '?db' at line 1
mysql>
I tried creating a database with a '?' in it and it also gives me syntax error. via ssh.
so how do I remove this database?
Try:
DROP DATABASE `testing?db`;