Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 9th, 2003, 02:37 PM
sree78 sree78 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 sree78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Need Help !! Concat Function in Posgresql

Hi,

I am new to posgres. I am trying to figure out how to use the concat function for my query as below:-

This query is for a search function which searches employee by their last and first name. The reason why i want to do the concat function is to enable the users to search both first and last name together (with a space e.g John Smith). This query works well with mysql but with posgres .. it is showing me and error.. I have tried using the (||) but yet I do get an error. Any help is highly appreciated.

php Code:
Original - php Code
  1.  
  2. <?php
  3. $query = "
  4. Select employee.empid, employee.fname, employee.lname, emp_info.phone, department.name
  5. FROM employee, department, emp_info
  6. WHERE lname='$emp' OR fname ='$emp'
  7. OR concat (lname,'',fname) ='$emp'
  8. AND employee.empid = emp_info.empid
  9. AND department.deptid = emp_info.deptid
  10. ORDER by employee.fname
  11. ";
  12. ?> 


$emp
-----
Is the search field name I have given in the form.

Have been a week and still could not find a breakthrough.

Thanks a lot in adv..

Reply With Quote
  #2  
Old September 10th, 2003, 12:21 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Need Help !! Concat Function in Posgresql

There is no concat function in postgresql..you say you have tried the || operator...what error do you ger?

Reply With Quote
  #3  
Old September 16th, 2003, 08:06 PM
Sxooter Sxooter is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Chicago, IL, USA
Posts: 20 Sxooter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Sxooter
RE: Need Help !! Concat Function in Posgresql

First, Postgresql, like almost all other databases, does NOT search varchar/text types case-insensitively. I.e. Scott is not the same as scott. You can either use ilike or regular expression searches to do what you want there. Note that ilike and regex do NOT generally use indexes, so if your table is big, it can be a bit slow.

So, you can do case insensitive searches like this:

select *
from phonebook
where pname||' '||lname
ilike 'joe smith';

or

select *
from phonebook
where pname||' '||lname
~* 'joe smith';

Reply With Quote
  #4  
Old September 16th, 2003, 10:40 PM
sree78 sree78 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 sree78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Need Help !! Concat Function in Posgresql

Hi...

thank you for your help, I will try your method and see if it works..


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Need Help !! Concat Function in Posgresql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT