 |
|
10th July 2008, 14:58
|
#11
|
|
Godlike
Join Date: Jul 2005
Posts: 10,101
|
Actually, I was thinking that the SQL using the OR and LIKE and SUBSTR is not going to be very efficient and is going to scan the data.
I am thinking of maintaining another column (via a trigger) to contain the first letter of the band name and if it is not a letter, store # in the field, so the SQL becomes:
SELECT band_name
FROM bands
WHERE band_name_begins = @p
And put an index on this column, as the data is rarely updated or added to, but read A LOT.
__________________
By the time you finish reading this sentence, the national debt will have risen by another £1,500 - which you or your children will have to repay.
Just so you know.
|
|
|
10th July 2008, 15:07
|
#12
|
|
Fingers like lightning
Join Date: Nov 2005
Posts: 678
|
There are no good bands which start with a number anyway. I'd just dump them all if I was you.
|
|
|
10th July 2008, 15:08
|
#13
|
|
Fingers like lightning
Join Date: Nov 2005
Posts: 678
|
Apart from 3 Mustaphas 3.
|
|
|
10th July 2008, 15:08
|
#14
|
|
Super poster
Join Date: Mar 2007
Location: London
Posts: 3,937
|
Quote:
Originally Posted by DimPrawn
That's in module 2, to be learned next week.
|
You are Bob Shawadiwadi AICMFP
Quote:
Originally Posted by DimPrawn
Actually, I was thinking that the SQL using the OR and LIKE and SUBSTR is not going to be very efficient and is going to scan the data.
I am thinking of maintaining another column (via a trigger) to contain the first letter of the band name and if it is not a letter, store # in the field, so the SQL becomes:
SELECT band_name
FROM bands
WHERE band_name_begins = @p
And put an index on this column, as the data is rarely updated or added to, but read A LOT.
|
Steady now, you'll start to look like a professional (and I don't mean Bodie or Doyle).
__________________
Level 20 Xeno Geek.
|
|
|
10th July 2008, 15:27
|
#15
|
|
Contractor Among Contractors
Join Date: Jul 2005
Location: the centre of the world - according to Jack Straw
Posts: 1,599
|
How many bands are you tracking? 100K? 1M? wow!
Besides you could just make a function index in oracle, or calculated column in SQL server and index it.
|
|
|
10th July 2008, 17:32
|
#16
|
|
Godlike
Join Date: Jul 2005
Posts: 10,101
|
Actually it's not bands. I just used that as an example.
__________________
By the time you finish reading this sentence, the national debt will have risen by another £1,500 - which you or your children will have to repay.
Just so you know.
|
|
|
10th July 2008, 17:47
|
#17
|
|
Super poster
Join Date: Jun 2007
Location: Your local branch
Posts: 2,601
|
Quote:
Originally Posted by DimPrawn
Actually it's not bands. I just used that as an example.
|
This is why one should use metasynctactic variables:
"Say you want to select all the rows in table "foo" having a value in the varchar field "bar" beginning with a specific character from a particular range of characters, or beginning with any character not in that range if some wildcard character is specified..."
That way people don't get distracted talking about nonsense like "How many bands are there in the world" and suchlike - they remain focused on solving the specific problem for the abstract case.
|
|
|
11th July 2008, 08:05
|
#18
|
|
Lurker not a fighter
Join Date: Mar 2008
Posts: 74
|
Have you considered...
SELECT band_name
FROM bands
WHERE band_name like (replace(@p,'#','[0-9]')+'%')
|
|
|
22nd July 2008, 11:44
|
#19
|
|
Contractor Among Contractors
Join Date: Jul 2005
Location: Behind you
Posts: 1,578
|
Quote:
Originally Posted by NickFitz
This is why one should use metasynctactic variables:
"Say you want to select all the rows in table "foo" having a value in the varchar field "bar" beginning with a specific character from a particular range of characters, or beginning with any character not in that range if some wildcard character is specified..." That way people don't get distracted talking about nonsense like "How many bands are there in the world" and suchlike - they remain focused on solving the specific problem for the abstract case.
|
I tend to create tables called "Select" with fields called "From" and "Order By".
It confuses the hell out of everyone else though. 
__________________
I need a new sig.
|
|
|
22nd July 2008, 11:48
|
#20
|
|
Godlike
Join Date: Jul 2005
Posts: 10,101
|
Quote:
Originally Posted by EvilWeevil
Have you considered...
SELECT band_name
FROM bands
WHERE band_name like (replace(@p,'#','[0-9]')+'%')
|
No. A good concise answer.
__________________
By the time you finish reading this sentence, the national debt will have risen by another £1,500 - which you or your children will have to repay.
Just so you know.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 21:51.
|  |
| Advertisers |
|
| Contractor Alliance |
Formed a new Ltd Co?
20% off business insurance
£10 off Bauer & Cottrell contract reviews
Find co-workers & client introductions
Increase your value to clients here
|
|