473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to deal with * in Mysql

43
in my table, there r some * like :

id name
1 aaa_***
2 abcddd
3 bbb_***
4 adaflkj

I wanna to change all * in this table to 9,
anybody who knows how to deal with * in Mysql.
Thanks,
Tanya
May 28 '07 #1
8 1437
Atli
5,058 Expert 4TB
The * character inside strings is treated like any other character, so you would have to replace it with some script, or manually, just like you would do with any other character.

This character is used by MySQL as a wildcard character. It can be used to replace table names or column names in places where you would like MySQL to use all available tables/columns.

For example:
Expand|Select|Wrap|Line Numbers
  1. SELECT myTbl.* FROM myTbl;
  2. GRANT ALL ON myDb.* to 'User';
  3.  
May 28 '07 #2
pbmods
5,821 Expert 4TB
Have a look at the replace function.
May 28 '07 #3
tanyali
43
The * character inside strings is treated like any other character, so you would have to replace it with some script, or manually, just like you would do with any other character.

This character is used by MySQL as a wildcard character. It can be used to replace table names or column names in places where you would like MySQL to use all available tables/columns.

For example:
Expand|Select|Wrap|Line Numbers
  1. SELECT myTbl.* FROM myTbl;
  2. GRANT ALL ON myDb.* to 'User';
  3.  
Thanks for answering,
MySql use * as a wildcard character, this is the problem !
in a linux terminal , using " \ " before " * " means the character " * " itself instead of any other character, so I am wondering is there any similar way to do in MySql ?
Tanya
May 29 '07 #4
pbmods
5,821 Expert 4TB
MySql use * as a wildcard character, this is the problem !
in a linux terminal , using " \ " before " * " means the character " * " itself instead of any other character, so I am wondering is there any similar way to do in MySql ?
If the * is in quotes or backticks, it won't get processed as a wildcard. In other words:

Expand|Select|Wrap|Line Numbers
  1. SELECT '*' FROM `someTable`
  2. SELECT `*` FROM `someTable`
  3. SELECT * FROM `someTable`
The first one will return one column, one row.
The second one will probably return an error, unless you have a field explicitly named `*` in `someTable`.
The third one will return all fields in `someTable`.
May 29 '07 #5
tanyali
43
If the * is in quotes or backticks, it won't get processed as a wildcard. In other words:

Expand|Select|Wrap|Line Numbers
  1. SELECT '*' FROM `someTable`
  2. SELECT `*` FROM `someTable`
  3. SELECT * FROM `someTable`
The first one will return one column, one row.
The second one will probably return an error, unless you have a field explicitly named `*` in `someTable`.
The third one will return all fields in `someTable`.
Yes !
this is actually what I want to get !
but how about inside of a string ?

I tried these : code (mysql )

1- delete from fcst where name = '???_`***`' ;
2- delete from fcst where name = '???_'***'' ;
3- delete from fcst where name = '*_`***`' ;
but none works.
I wanna to delete all records which end with *** .

Tanya
May 30 '07 #6
pradeep kaltari
102 Expert 100+
Yes !
this is actually what I want to get !
but how about inside of a string ?

I tried these : code (mysql )

1- delete from fcst where name = '???_`***`' ;
2- delete from fcst where name = '???_'***'' ;
3- delete from fcst where name = '*_`***`' ;
but none works.
I wanna to delete all records which end with *** .

Tanya
Hi Tanya,
Try the following:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM table_name
  2. WHERE col_name LIKE '%***'
  3.  
% will try to match zero or more characters. The WHERE clause specifies that the col_name should end with ***. Also note that I have used LIKE operator, if you try to use "=" in place of LIKE the query will delete only the records where the value of col_name is '%***'.

I hope this helps you.

Regards,
Pradeep
May 30 '07 #7
tanyali
43
Hi Tanya,
Try the following:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM table_name
  2. WHERE col_name LIKE '%***'
  3.  
% will try to match zero or more characters. The WHERE clause specifies that the col_name should end with ***. Also note that I have used LIKE operator, if you try to use "=" in place of LIKE the query will delete only the records where the value of col_name is '%***'.

I hope this helps you.

Regards,
Pradeep
Hi Pradeep,

I solved this problem, thank you so much !

Tanya
May 31 '07 #8
pradeep kaltari
102 Expert 100+
Hi Pradeep,

I solved this problem, thank you so much !

Tanya
Glad to help you.

Regards,
Pradeep
May 31 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: _mario lat | last post by:
I'd like to deal (update, deal, insert....) a database (with tables and relationship between these) by a tool written in php. I need to share and work on a database with other people. I'd like to...
2
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
4
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
2
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on...
2
by: Richard | last post by:
Hi All, I'm running MySQL 5.0.15-nt running over WinXP-Pro/SP2. The following group of commands and responses suggests to me that my installation of MySQL is corrupted. Is there anyway I can...
1
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
3
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.