1 Replies - 2393 Views - Last Post: 13 September 2012 - 09:45 PM

#1 Sasquatch3o3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 03-April 11

SQL Query

Posted 13 September 2012 - 08:01 PM

Classes (class, type, country, numGuns, bore, displacement)
Ships(name, class, launched)
Battles(name, date)
Outcomes(ship, battle, result)

Find the names of all ships whose name consists of three or more words.

I have
SELECT name
FROM Ships
WHERE name LIKE '% % %';


It still returns every tuple in the database, I have no idea where to go from here, any help is greatly appreciated.

This post has been edited by Atli: 13 September 2012 - 09:34 PM
Reason for edit:: Please use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Replies To: SQL Query

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: SQL Query

Posted 13 September 2012 - 09:45 PM

I'd try using the REGEXP_COUNT function.
SELECT name
FROM Ships
WHERE REGEXP_COUNT(name, ' +') > 2


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1