SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 5th, 2012, 05:35 PM
TomHand TomHand is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 TomHand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 sec
Reputation Power: 0
How to use SQL to query this complex structure? Please help!?

I have this table T1, it has 3 columns:
The first column is Integer, the 2nd & the 3rd is string. These are some sample data in table T1:

1 S1 A
1 B C
2 S2 A
2 B C
3 s3 C
3 B A
4 s4 K
4 K T
4 T Y
5 S5 A
5 B C
6 S6 A
6 K L
7 S7 T
7 B C

Suppose I wanna query all the groups that has this format:
? A
B C

--> so if the query executes correctly, it will show these result
1 S1 A
1 B C
2 S2 A
2 B C
5 S5 A
5 B C

The query should not show 6 or 7 as 6 or 7 only 1 row matching.

Note: the result must go with the whole group.

Can anyone show me how to form SQL to query this?
Thax u

Last edited by TomHand : November 5th, 2012 at 06:36 PM.

Reply With Quote
  #2  
Old November 7th, 2012, 10:38 PM
narrokk narrokk is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 narrokk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 45 sec
Reputation Power: 0
Suppose i have this query

select * from northwind where name like 'A%'

this would show results which are like:

APRIL

APPLE

ASADSAD

AND

(all that starts with A)

now for your question, I SUPPOSE that all your data has @@[]A
where @ = any digit or letter, followed by [] which indicates open space and A which is an end statement, you could use

select * from northwind where name like '%A'

it would show

A1 A
b2 A
c3 A

and so forth,

or you would use,

select * from northwind where name like 'S% A'

this would produce

S1 A
S2 A
S3 A
S4 A

I HOPE THIS HELPED

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > How to use SQL to query this complex structure? Please help!?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap