|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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:
$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.. |
|
#2
|
|||
|
|||
|
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?
|
|
#3
|
|||
|
|||
|
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'; |
|
#4
|
|||
|
|||
|
RE: Need Help !! Concat Function in Posgresql
Hi...
thank you for your help, I will try your method and see if it works.. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Need Help !! Concat Function in Posgresql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|