If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > stored procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-23-10, 03:40
tchiloh tchiloh is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
stored procedures

i want do:

1:
Select code
from eancodes
where eancode = parameter1;

2:
Select price
from articles
where code = ........

i want instead of ..... the code that i have selected from 1.
how do i that?
Reply With Quote
  #2 (permalink)  
Old 03-23-10, 03:59
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
Select price
from articles
where code IN
(
Select code
from eancodes
where eancode = parameter1
)
__________________
Florin Aparaschivei
Iasi, Romania
Reply With Quote
  #3 (permalink)  
Old 03-23-10, 04:24
tchiloh tchiloh is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
thank you!

now it's working

Last edited by tchiloh; 03-23-10 at 04:51.
Reply With Quote
  #4 (permalink)  
Old 03-23-10, 10:44
tchiloh tchiloh is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
i get only the value from code. but i want values from code, name and city.

what do i wrong:

Quote:
CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure`(IN Parameter1 INT)
BEGIN

select Code
from codes
where Code = Parameter1;

select name, city
from country
where city = 'Agadir';
END
Reply With Quote
  #5 (permalink)  
Old 03-24-10, 05:55
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
I am not sure what exactly you want to accomplish, but you have two SELECT statements, from different tables, so you might need a JOIN.
__________________
Florin Aparaschivei
Iasi, Romania
Reply With Quote
  #6 (permalink)  
Old 03-26-10, 05:26
tchiloh tchiloh is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
what is the value of a emty field.

Quote:
DECLARE temp int(11);

SELECT OrderNr
INTO temp
FROM Orders
WHERE ID = 5;

IF temp = NULL
THEN temp = 7
END IF;
i tryed with temp = 0 and temp = NULL and temp < 2.
But he comes never in the if statement. he go's only to the else statement
Reply With Quote
  #7 (permalink)  
Old 03-26-10, 06:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
try IS NULL

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 03-29-10, 05:29
tchiloh tchiloh is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
how can i select between 2 dates.

i have now

select sum(aantal)
from drank
where datum BETWEEN DATE(NOW(), INTERVAL -7) AND NOW();
Reply With Quote
  #9 (permalink)  
Old 03-29-10, 06:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
WHERE datum BETWEEN CURRENT_DATE - INTERVAL 7 DAY AND CURRENT_DATE

will give you rows up until but not including today


WHERE datum BETWEEN CURRENT_DATE - INTERVAL 7 DAY AND CURRENT_TIMESTAMP

will give you rows up until the current time today
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On