Wednesday 15 May 2013

sql - Select row if sub string exist in column otherwise select all rows -


I am trying to select a record from an Access 2010 query, based on whether the text in this field Contains all the strings in However, if the sub string is not present, then it should return all the rows in the query.

For example, the following archives have been given:

  User Fruit ---- ----- Fred Apple George Kelly Mary Apple Mike Pears John Pears   



If 'Apple' SQL is specified in the WHERE clause, then I hope the records will be returned:

  User Fruit --- - --- - If Apple SQL is not specified in the WHERE section, then I hope the records will be returned:  
  Uses Narta Fruit ---- ----- George Kane Mike Pair John Pair   



This is a simple question and it is a one-time choice (I.e. fruit) criteria is quite complex as the real question. However, I can not do it for a unique or one or the other, but not to both.

Regards

Something like that, I think:

  Select from table where fruit = 'apple' or 0 = (selection number (1) where fruit is the result of = 'apple')    

No comments:

Post a Comment