13 Replies - 1072 Views - Last Post: 30 September 2009 - 12:18 PM Rate Topic: -----

#1 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

SQL

Post icon  Posted 29 September 2009 - 07:59 PM

Hi people I have problem with SQL statements i almost have no idea of database programing. I create a table for a pancake restaurant the table has 38 pancakes that are made from different kind of fruits I am trying to write a code that should display all pancakes that include strawberry and that do not include strawberry I wrote some statements and are all wrong .Please if anyone has an idea how I should do that. Thank you

  select strawberry
	from pancakes

select pancake_number, pancake_name
from pancakes
where strawberry




Is This A Good Question/Topic? 0
  • +

Replies To: SQL

#2 illicit  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 01-August 09

Re: SQL

Posted 29 September 2009 - 11:13 PM

View Postpomak, on 29 Sep, 2009 - 06:59 PM, said:

Hi people I have problem with SQL statements i almost have no idea of database programing. I create a table for a pancake restaurant the table has 38 pancakes that are made from different kind of fruits I am trying to write a code that should display all pancakes that include strawberry and that do not include strawberry I wrote some statements and are all wrong .Please if anyone has an idea how I should do that. Thank you

  select strawberry
	from pancakes

select pancake_number, pancake_name
from pancakes
where strawberry




Could you please give a screenshot of your database so i can see what to select and where from etc. :)
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Head MFIC
  • member icon

Reputation: 5066
  • View blog
  • Posts: 26,449
  • Joined: 10-May 07

Re: SQL

Posted 29 September 2009 - 11:15 PM

View Postpomak, on 29 Sep, 2009 - 08:59 PM, said:

I am trying to write a code that should display all pancakes that include strawberry

select pancake_number, pancake_name
from pancakes where *column*='strawberry';

Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: SQL

Posted 30 September 2009 - 07:14 AM

View Postno2pencil, on 30 Sep, 2009 - 02:15 AM, said:

View Postpomak, on 29 Sep, 2009 - 08:59 PM, said:

I am trying to write a code that should display all pancakes that include strawberry

select pancake_number, pancake_name
from pancakes where *column*='strawberry';


and in this query, the "column" is the name of the column where "strawberry" would be.
Was This Post Helpful? 0
  • +
  • -

#5 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

Re: SQL

Posted 30 September 2009 - 07:20 AM

View Posteclipsed4utoo, on 30 Sep, 2009 - 06:14 AM, said:

View Postno2pencil, on 30 Sep, 2009 - 02:15 AM, said:

View Postpomak, on 29 Sep, 2009 - 08:59 PM, said:

I am trying to write a code that should display all pancakes that include strawberry

select pancake_number, pancake_name
from pancakes where *column*='strawberry';


and in this query, the "column" is the name of the column where "strawberry" would be.




I tried it but still does not work I am getting this message: ORA-00936: missing expression
Was This Post Helpful? 0
  • +
  • -

#6 rgfirefly24  Icon User is online

  • D.I.C Lover
  • member icon


Reputation: 260
  • View blog
  • Posts: 1,419
  • Joined: 07-April 08

Re: SQL

Posted 30 September 2009 - 07:34 AM

You need to give us the query you tried.


the select statement you were given should have worked with out issue.

Also give us the Design of your table(s) so that we can better know what we are dealing with.
Was This Post Helpful? 0
  • +
  • -

#7 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

Re: SQL

Posted 30 September 2009 - 07:44 AM

View Postrgfirefly24, on 30 Sep, 2009 - 06:34 AM, said:

You need to give us the query you tried.


the select statement you were given should have worked with out issue.

Also give us the Design of your table(s) so that we can better know what we are dealing with.



This is what I tried

select pancake_number,pancake_name
from pancakes
where *pancake_description*='strawberry';


PANCAKE_NUMBER PANCAKE_NAME PANCAKE_DESCRIPTION PANCAKE_PRICE
1 Pancake Around the Clock Incredibly large moist buttermilk pancakes this one makes the world go round. 6.5
6 Tropical Awareness pineapple and coconut pancakes 6.95
9 Pancake Delight cherries, coconut, raisin, need i say more 7.5
10 Fruit Integration loaded with apple, blueberry and cranberry 6.95
13 Strawberry Consciousness luscious fresh strawberry pancakes (cooked in or topped with) 6.95
14 Maine Delicacy whole grain and blueberry pancakes 6.95
18 Desperately Healthy Pancakes oatmeal and raisin buttermilk pancakes, pancakes at their best 6.95
21 Milky Way loads of chocolate chips make this luscious treat 7.95
22 Heavenly Celestial Body white chocolate chips and almond pancakes 7.95
28 Apple Orchard apple, cinnamon, walnut, cranberry and raisin pancakes 7.5
29 Strawberry Banana Pancakes strawberries and bananas make this a gourmet delight 6.75
33 Triple Chocolate chocolate batter chocolate chunks, and topped with chocolate syrup 8.5
34 Oatmeal Flapjacks chocolate chips in the batter with fresh strawberries and banana on top 8.5
35 Red, White, and Blue Pancakes strawberry banana and blueberry 8.5
36 Fancy Dark Cherries Chocolate Chips Pancakes cherries and chocolate chips 8.5
2 California Craze Outrageous raisin pancakes. 6.5
3 Banana Euphoria bananas, bananas, bananas, in every bite 6.95
4 Yankee Peddler pancakes oozing with ripe blueberries 7.5
5 Pancake Vision raisins, cinnamon, giant apple and nuts fill these beauties 7.5
7 Cherry Treat large luscious, pancakes, loaded with dark bing cherries 6.95
8 Do It Again a combination of blue berries and bananas, you'll definitely come for them again 6.95
11 Polynesian Special bananas, pineapples and coconut 8.5
12 Strawberry, banana and Chocolate Chip strawberry, chocolate chips and banana 6.95
15 English Treasure whole wheat raisin pancakes 6.95
16 Massachusetts Nut hazelnut and raisin pancakes 6.95
17 Enzyme Special papaya and pineapple, this is new 6.95
19 Summertime harvest special raised buckwheat, raisin and spice pancakes (4 medium) 6.95
20 Chocolate Lovers batter liberally mixed with rich milk chocolate chunks 7.95
23 Addictive Delight chocolate chips and peanut butter chips pancakes 7.95
24 Great Cocoa natural cocoa and peanut butter chips you'll love them 7.95
25 Edge of the Garden assorted berries make these the taste of the century 7.5
26 Strawberry Pineapple Pancakes a perfect mixture of strawberries and pineapple a favorite 6.95
27 Peaches, Banana and Strawberry Pancakes bananas, peaches and strawberry 6.95
30 Health Nut Pancakes oat bran raisins and nuts mixed in our buttermilk pancakes 6.95
31 Halloween Feast pumpkin and spice pancakes 6.95
32 Combination of the best maple, peaches and walnut pancakes 7.5
37 Banana and Chocolate Chips Pancakes banana and chocolate chips 8.5
38 White Chocolate, Banana and Almond Pancakes chocolate, banana and alnond 8
Was This Post Helpful? 0
  • +
  • -

#8 danny_kay1710  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 28
  • View blog
  • Posts: 358
  • Joined: 27-April 08

Re: SQL

Posted 30 September 2009 - 07:57 AM

View Postpomak, on 30 Sep, 2009 - 01:44 PM, said:

select pancake_number,pancake_name
from pancakes
where *pancake_description*='strawberry';



you were almost right:
select pancake_number,pancake_name
from pancakes 
where pancake_description='strawberry'; 



The stars were to denote you needed to do something and not type as it was. Also if your field names are in uppercase some database servers require your sql to have the field names in uppercase.

EDIT: Looking back over your reply, that might not quite fit your needs. If i understand this correctly you want the results containing strawberry so you would need to use Like

select pancake_number,pancake_name
from pancakes 
where pancake_description Like '*strawberry*'; 



More info: http://www.sql-tutor...et/SQL-LIKE.asp

This post has been edited by danny_kay1710: 30 September 2009 - 08:01 AM

Was This Post Helpful? 0
  • +
  • -

#9 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

Re: SQL

Posted 30 September 2009 - 08:07 AM

View Postdanny_kay1710, on 30 Sep, 2009 - 06:57 AM, said:

View Postpomak, on 30 Sep, 2009 - 01:44 PM, said:

select pancake_number,pancake_name
from pancakes
where *pancake_description*='strawberry';



you were almost right:
select pancake_number,pancake_name
from pancakes 
where pancake_description='strawberry'; 



The stars were to denote you needed to do something and not type as it was. Also if your field names are in uppercase some database servers require your sql to have the field names in uppercase.

EDIT: Looking back over your reply, that might not quite fit your needs. If i understand this correctly you want the results containing strawberry so you would need to use Like

select pancake_number,pancake_name
from pancakes 
where pancake_description Like '*strawberry*'; 



More info: http://www.sql-tutor...et/SQL-LIKE.asp



Now it is telling me this: no data found
Was This Post Helpful? 0
  • +
  • -

#10 ForcedSterilizationsForAll  Icon User is offline

  • D.I.C Addict

Reputation: 33
  • View blog
  • Posts: 506
  • Joined: 16-July 09

Re: SQL

Posted 30 September 2009 - 10:53 AM

SQL Server uses % as a wildcard. Are you using SQL Server to do the query?
Was This Post Helpful? 0
  • +
  • -

#11 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: SQL

Posted 30 September 2009 - 11:06 AM

Two things. One is the previously mention wild card, the other is the Oracle is case sensitive.

Try this:
select pancake_number, pancake_name
   from pancakes
   where lower(pancake_description) like '%strawberry%'
	  or lower(pancake_name) like '%strawberry%'


Was This Post Helpful? 0
  • +
  • -

#12 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

Re: SQL

Posted 30 September 2009 - 11:31 AM

View PostForcedSterilizationsForAll, on 30 Sep, 2009 - 09:53 AM, said:

SQL Server uses % as a wildcard. Are you using SQL Server to do the query?





Yes I am using SQL server
Was This Post Helpful? 0
  • +
  • -

#13 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: SQL

Posted 30 September 2009 - 12:03 PM

View Postpomak, on 30 Sep, 2009 - 12:31 PM, said:

Yes I am using SQL server


:blink: um, ok....

View Postpomak, on 30 Sep, 2009 - 08:20 AM, said:

I tried it but still does not work I am getting this message: ORA-00936: missing expression


Your SQL Server throws Oracle errors at you? You may have bigger problems. :P

This post has been edited by baavgai: 30 September 2009 - 12:03 PM

Was This Post Helpful? 0
  • +
  • -

#14 pomak  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 01-November 08

Re: SQL

Posted 30 September 2009 - 12:18 PM

View Postbaavgai, on 30 Sep, 2009 - 11:03 AM, said:

View Postpomak, on 30 Sep, 2009 - 12:31 PM, said:

Yes I am using SQL server


:blink: um, ok....

View Postpomak, on 30 Sep, 2009 - 08:20 AM, said:

I tried it but still does not work I am getting this message: ORA-00936: missing expression


Your SQL Server throws Oracle errors at you? You may have bigger problems. :P



Sorry very much I am not using SQL I am using Oracle iLearning Academy it is web based server or something like that
I am not so familiar with Oracle or SQL I started like 3 weeks ago I paid for this so I can create tables,query and practice code it is self learning program
I want to be more educated about Oracle
Sorry again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1