Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query to find rows where a field "Begins with"

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-12-04 : 08:16:39
Derek writes "I'm totally new to SQL and need some help.

I need to write a query that will return rows where a specific field begins with a selected string.
Example:
My table is called rf_log

I want to see all rows where the PACKSLIP begins with 'ORD000888'

I tried:
Select *
from rf-log
where PACKSLIP like 'ORD000888'

This returns only rows where the packslip is = ORD000888

I need to see all rows where the packslip begins with ORD000888.
So packslip ORD000888-0, ORD000888-1 and ORD000888-2 should also be returned.

Many thanks."

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-04 : 08:20:10
[code]Select *
from rf-log
where PACKSLIP like 'ORD000888%'[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 08:20:15
select * from rf_log where packslip LIKE 'ORD000888%'


Peter Larsson
Helsingborg, Sweden

Echo On:
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-12-04 : 09:05:41
Is there an echo in here?

ECHO OFF







Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 09:19:45
It's called "the Harsh Effect"...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 09:36:49

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-04 : 09:43:12
No..It's "The Peso Effect Rediscovered!"

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 10:31:58
quote:
Originally posted by harsh_athalye

No..It's "The Peso Effect Rediscovered!"

Harsh Athalye
India.
"Nothing is Impossible"

Faster than Peso


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-04 : 10:36:57
quote:
Faster than Peso


Rarely!

Poster              Average Posts
----------------------------------
Peter 20.50
me 7.81


Way behind !

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 10:39:55
[code]Peso 08:20:15
Harsh 08:20:10[/code]Seems like a five second lead to me


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-04 : 11:16:21
I was lucky this time!

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 11:20:46
Sure. Just pure luck?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -