Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 31st, 2008, 12:59 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Evaluate string in the where clause

Hello

Can you compare strings in a where clause? EG:

SELECT DISTINCT myStrigField FROM tblename WHERE myStringField [starts with 'ABC_D'] ORDER BY myStrigField;"

mmmm, seems simple however is proving otherwise...
The objective of this query is to pull all distinct records that start with 'ABC_D'

The LEFT function (and other common string functions) seem to be used to massage the output syntax however I am having difficulty conditionaly selecting my record set. I am aware I can make this comparison while looping through the RS however would prefer to get just the records I need as described above.

TYIA

Wind is your friend
Matt
www.elitemarquees.com.au
__________________
Wind is your friend
Matt
Reply With Quote
  #2 (permalink)  
Old January 31st, 2008, 03:57 AM
Registered User
 
Join Date: Jan 2008
Location: , , India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can do it by using LIKE operator.
e.g:
  SELECT DISTINCT myStrigField FROM tblename WHERE myStringField LIKE 'ABC_D%' ORDER BY myStrigField

Reply With Quote
  #3 (permalink)  
Old January 31st, 2008, 04:57 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Than you for your time however this will get all records where the string contains 'ABC_D'

My question remains.... (frankly I dont think its possible, can anybody clarify this??)

TYIA

Wind is your friend
Matt
www.elitemarquees.com.au
Reply With Quote
  #4 (permalink)  
Old February 1st, 2008, 12:32 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

I think following could help you, if I am wrong please correct me.

SELECT * FROM tblename WHERE myStringField LIKE 'ABC_D%' ORDER BY myStrigField


urt

Help yourself by helping someone.
Reply With Quote
  #5 (permalink)  
Old February 1st, 2008, 01:51 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

urtrivedi - Thankyou for your time however your suggestion is the same as issaq's. This will not achieve the objective for the same reason in my last post.


Wind is your friend
Matt
www.elitemarquees.com.au
Reply With Quote
  #6 (permalink)  
Old February 1st, 2008, 02:07 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Apologies, I didnt look at your post very well did i....

Let me try that, looks logical to me.

Wind is your friend
Matt
www.elitemarquees.com.au
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to evaluate parameter? chobo XSLT 8 February 25th, 2008 07:05 AM
Evaluate responseText from Server.aspx peace2007 Ajax 8 January 4th, 2008 06:47 AM
XPath Evaluate Document safin XML 2 September 19th, 2005 07:29 AM
evaluate the size of a file BEFORE it gets uploade ALEX_GRIM ASP.NET 1.0 and 1.1 Professional 7 May 10th, 2005 10:30 PM
How do i evaluate A_josh VB How-To 1 December 22nd, 2003 01:47 PM



All times are GMT -4. The time now is 02:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.