473,387 Members | 1,757 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,387 software developers and data experts.

Selective concat in query?

2
I'm trying to run a query in MySQL Query Browser that will concat 3 fields together to form a single date format. This part I don't have a problem with:

SELECT CONCAT(`Field12`, '/', `Field13`, '/', `Field11`) FROM `mini`;

However, not all rows have these fields filled, and I end up with / / in the result. I would like to do something such as

SELECT IF(`Field12` IS NOT NULL THEN CONCAT(`Field12`, '/', `Field13`, '/', `Field11`) ELSE ' ') FROM 'mini';

Any way to get this working properly?
Jun 6 '08 #1
2 1769
cubix
2
Just to clarify, I still want the blank row, this is only a snippet of a much larger query that converts and entire flat table into a different format.


I did manage to achieve the a almost perfect result with

SELECT date_format(str_to_date(CONCAT(`Field12`, `Field13`, `Field11`), "%m%d%Y"), "%m/%d/%Y")FROM `mini`;

seems very redundant :-D
And now I get NULL in my results
Jun 6 '08 #2
r035198x
13,262 8TB
Use the IFNULL function.
Jun 9 '08 #3

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

Similar topics

2
by: delgados129 | last post by:
I've seen a few XSL examples to flatten a specific node, but none that address this specific scenario: Given the following generic XML: <DocElement> <A attr="attribForA">TextForA</A>...
8
by: May | last post by:
Hi, My question is: How to concat values from several lines (the same column) to only one value. For example: We have table SGMENT with one column: NAME (varchar2(50)). We would like to have...
0
by: Roy | last post by:
I used your Concat query in one of my application,with a lil change.I am trying to concatenate a text field using a number field as the key field. Application:...
3
by: nickdevx | last post by:
Damn it this "illegal mix of collashit" messages are driving me nuts!! What's wrong with the following statement? SELECT userid, CONCAT(username,' / ',firstname,' ',lastname,' / ', email,...
4
by: Martin Evans | last post by:
Hi, I'm getting: DBD::DB2::db do failed: SQL0440N No authorized routine named "CONCAT" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884 for some SQL like this:
17
by: ramadu | last post by:
I know its a sin to use strings, lets skip that part... Which of these is faster and uses less memory? String.Format("SomeValue='{0}'", m_Value); or String.Concat("SomeValue='", m_Value,...
4
by: alex.hatzisavas | last post by:
Dear all, I'm trying to do a selective deletion from an 'Archive' table based on dates. Here is the setup: Table 'Archive' has a date field ( ). Another table ('Cutoffs') defines the Low...
4
by: waqasahmed996 | last post by:
hi to all i have three fields of name in database named as fnam,mname,lname. fname and lname is mandatory field and mname is optional. i want to make a search query on name ...
3
by: shanmugamit | last post by:
HI, i need solution for dynamic query in stored procedure without concat. How to create dynamic query like pagination passing limit value. IF category='artist' THEN IF lim=0 THEN SET...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.