Need Help !! Concat Function in Posgresql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
sree78
Forum Commoner
Posts: 39
Joined: Tue May 20, 2003 11:38 am

Need Help !! Concat Function in Posgresql

Post by sree78 »

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). 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.

Code: Select all

<?php 
$query = " 

Select employee.empid, employee.fname, employee.lname, emp_info.phone, department.name 
FROM employee, department, emp_info 
WHERE lname='$emp' OR fname ='$emp' 
OR concat (lname,'',fname) ='$emp' 
AND employee.empid = emp_info.empid 
AND department.deptid = emp_info.deptid 
ORDER by employee.fname 

"; 
?>



$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.. :roll:
ericsodt
Forum Commoner
Posts: 51
Joined: Fri Aug 22, 2003 12:12 pm
Location: VA

Re: Need Help !! Concat Function in Posgresql

Post by ericsodt »

get the database documentation and look up concat... thats the only I think I could do
sree78 wrote: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). 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.

Code: Select all

<?php 
$query = " 

Select employee.empid, employee.fname, employee.lname, emp_info.phone, department.name 
FROM employee, department, emp_info 
WHERE lname='$emp' OR fname ='$emp' 
OR concat (lname,'',fname) ='$emp' 
AND employee.empid = emp_info.empid 
AND department.deptid = emp_info.deptid 
ORDER by employee.fname 

"; 
?>



$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.. :roll:
Post Reply