Solved

Codeignitor Query

Posted on 2016-08-26
1
33 Views
Last Modified: 2016-09-09
I have a query that works but I need to add to it and I am not sure how.  I need to pull two different fields.

Right now it looks like this
<?php
  SELECT
                CASE
                    WHEN o.business_type_id = 1 THEN o.first_name
                    WHEN o.business_type_id = 4 THEN o.legal_name 
                    ELSE o.business_name
                END 

Open in new window


But I need to pull the First_Name and the Last_Name

Like this:
<?php
  SELECT
                ### Line 1 ###
                CASE
                    WHEN o.business_type_id = 1[b] THEN o.first_name AND .o.last_name[/b]
                    WHEN o.business_type_id = 4 THEN o.legal_name 
                    ELSE o.business_name
                END 

Open in new window

0
Comment
Question by:rgranlund
1 Comment
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 41772552
try if it supports CONCAT.
<?php
  SELECT
                CASE
                    WHEN o.business_type_id = 1 THEN CONCAT(o.first_name, o.last_name)
                    WHEN o.business_type_id = 4 THEN o.legal_name 
                    ELSE o.business_name
                END 

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question