Home » SQL & PL/SQL » SQL & PL/SQL » select username
select username [message #218128] Tue, 06 February 2007 23:07 Go to next message
matrik02
Messages: 64
Registered: November 2005
Member
I have a problem.. How I can select the username start with M in the student field name from table record?I forgot

Muiz
Mohammad
Molzairy
Molz
and so on
Re: select username [message #218131 is a reply to message #218128] Tue, 06 February 2007 23:19 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

hi,
select username
from tablename
where username like 'M%';

regards
Taj
Re: select username [message #218133 is a reply to message #218128] Tue, 06 February 2007 23:20 Go to previous messageGo to next message
rzkhan
Messages: 345
Registered: March 2005
Senior Member
select student from record
where student like 'M%';

Re: select username [message #218210 is a reply to message #218133] Wed, 07 February 2007 05:47 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Or
select student 
from   record
where  substr(student,1,1) = 'M';
Re: select username [message #218431 is a reply to message #218210] Thu, 08 February 2007 03:25 Go to previous messageGo to next message
SITO
Messages: 19
Registered: March 2005
Location: SWE
Junior Member
Is one of the above solutions to prefer above the other one in terms of performance ?

[Updated on: Thu, 08 February 2007 03:25]

Report message to a moderator

Re: select username [message #218442 is a reply to message #218431] Thu, 08 February 2007 04:06 Go to previous message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
I think it depends on indexes also.
If you are having index on student, "like" perform better than "substr" query.
If you create a substr function index on student then "substr" query also perform well.

In my test case "substr" query is performing better, if I'm having both indexes. But I'm not sure though.

By
Vamsi
Previous Topic: IN param substiution problem....
Next Topic: rownum problem
Goto Forum:
  


Current Time: Wed Dec 07 10:53:09 CST 2016

Total time taken to generate the page: 0.06806 seconds