Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2008, 12:59 AM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old January 31st, 2008, 03:57 AM
Registered User
 
Join Date: Jan 2008
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

 
Old January 31st, 2008, 04:57 PM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old February 1st, 2008, 12:32 AM
Friend of Wrox
 
Join Date: Oct 2007
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.
 
Old February 1st, 2008, 01:51 AM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old February 1st, 2008, 02:07 AM
Friend of Wrox
 
Join Date: Jan 2004
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





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





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