472,096 Members | 1,193 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

using LEN to find a first word greater than 17

how do i write a sql (ORACLE) statement for where the first word in
the name field is greater than 17 chars?
if i do this

SELECT businessname
FROM tablename
WHERE LEN(businessname) 17;

it will return all records when the combined length of words is
greater than 17.
i only want to check if the first word is greater than 17
Jun 27 '08 #1
1 3182
This is SQL Server newsgroup, so here is how you can do it in SQL Server.
For Oracle you have to check the Oracle newsgroups.

CREATE TABLE Foo (
keycol INT PRIMARY KEY,
businessname VARCHAR(50));

INSERT INTO Foo VALUES(1, 'Tools');
INSERT INTO Foo VALUES(2, 'Someverylongbusinessname Inc.');
INSERT INTO Foo VALUES(3, 'Short Inc.');
INSERT INTO Foo VALUES(4, 'Anotherverylongbusinessname');

SELECT businessname
FROM Foo
WHERE CHARINDEX(' ', businessname + ' ') 18;

HTH,

Plamen Ratchev
http://www.SQLStudio.com

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

121 posts views Thread by typingcat | last post: by
4 posts views Thread by Chris | last post: by
11 posts views Thread by Dorsa | last post: by
8 posts views Thread by John Salerno | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.