0

I have a clarification in SQL where condition, how do I use multiple columns combination in where conditions?

For example:

select *
from employees
where employee_firstName+employee_lastName = @emp_FirstName+@emp_LastName

I want the combination of the two parameters together.

I am using Sybase. Can anyone help me please?

mohsensajjadi
  • 325
  • 1
  • 6
  • 18
Nagarajan
  • 432
  • 3
  • 12
  • 28

2 Answers2

3

I can't test it, but should work faster:

select *
from employees
where employee_firstName = @emp_FirstName
  and employee_lastName  = @emp_LastName
mu is too short
  • 426,620
  • 70
  • 833
  • 800
Alexander Molodih
  • 1,928
  • 2
  • 20
  • 30
1

you should use concatenation operator, as described here:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks248.htm

select *
from employees
where (employee_firstName+employee_lastName) = (@emp_FirstName+@emp_LastName)
maialithar
  • 3,065
  • 5
  • 27
  • 44
  • Thanks Alexander and maialithar, Its worked for me, i tried with (employee_FirstName+employee_LastName) = (@emp_FirstName+@emp_LastName) .. Working Fine .. Thanks realy helpful for me!!!!! guys.. – Nagarajan Sep 19 '11 at 07:10
  • Not only this is non-sargable, but it can also return unexpected rows. For instance, if you searched for `Mariah Olbert`, you might additionally get `Maria Holbert`, and vice versa. – Andriy M Sep 19 '11 at 09:16