LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-11-2012, 12:00 PM   #1
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
SQL format output


Hi Folks,

Does any one know of any function in SQL that lets me format the output returned from a SELECT query ? From the output below,id like to get anything that is to the left of '-'. I can do this in a programming language butid like to try this through SQL.

Quote:
mysql> select post from table where col like 'z%';
+-------------+
| post |
+-------------+
| Z01-C3 |
| Z101-ZZ1 |
| Z21-PG4 |
| Z8202-G21 |
----------------

Intended output:
Z01
Y101
R21
 
Old 10-11-2012, 01:00 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
http://dev.mysql.com/doc/refman/5.0/...ubstring-index should do the trick
 
Old 10-15-2012, 09:19 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
mysql -e "use zabbix; select description from triggers;" -Ns
output:
Code:
...
WEB (HTTP) server is down on {HOSTNAME}
Zabbix_agentd is not running on {HOSTNAME}
Zabbix_server is not running on {HOSTNAME}
{HOSTNAME} has just been restarted
Version of zabbix_agent(d) was changed on {HOSTNAME}
WEB (HTTP) server is down on {HOSTNAME}
Server {HOSTNAME} is unreachable
rdp on {HOSTNAME} is unreachable
...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [Help] format text file for import into SQL table (with sed or similar) totaluser Linux - Newbie 3 11-05-2011 03:57 PM
Best video format for YouTube upload and can Recordmydesktop output that format? linus72 Linux - Software 6 12-21-2009 03:53 PM
sql output generates on a os text file ! shipon_97 Linux - General 0 01-14-2009 05:46 AM
Format SQL Results with PHP delamatrix Programming 6 10-21-2008 09:56 PM
How to store SQL output in a variable atulsh General 1 09-18-2008 01:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration