0

Hii
I Have Facing with Order problem
i try to query From Table

it go like this ->

SELECT * FROM Client
WHERE (ClientName LIKE 'X%') OR (ClientName LIKE '%[ ]X%')

It mean give me all clients that start Whit X Letter And Included MiddleName If There is And Last Name. but With Out Ordering!!

And i need to Order it!!
first by Name after it by MiddleName and by LastName...

for example -> ClientName
Erorn Mikel Bon Joi
Jack clint cary
Erorn Mikel Bon Jacov
mohamd abo jaml habdalhaa
jaber mahmoud ben saber

now query all names that Start With 'J'!

result need to look like this
1. Jack clint cary
2. jaber mahmoud ben saber
3. mohamd abo jaml habdalhaa
4. Erorn Mikel Bon Jacov
5. Erorn Mikel Bon Joi

i don't know how to order it,
Someon Have an idea how to start ?

eyal.c

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by eeyc
0

I cant distinguish between first, middle, and last names in the sample you provided so I can't answer your question.

Please use code tags when posting queries:

[code=sql] ...query here....

[/code]

Also use this for pasting text:

[code=text] ...text here]

[/code]

Use the text paste to line up columns with their column names and values.

0

Try like this

SELECT * FROM ClientWHERE (ClientName LIKE 'Anne%') OR (ClientName LIKE '%[ ]Anne%')
ORDER By  PATINDEX ( 'Anne%', ClientName) DESC
, PATINDEX ( '%[ ]Anne%', ClientName)

Here replace the name 'Anne' whatever you want.

Edited by Ramesh S: n/a

0

Ramesh Thank's For your help
It works just fine
thank's

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.