Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2009
    Posts
    18

    Unanswered: 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?

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Select price
    from articles
    where code IN
    (
    Select code
    from eancodes
    where eancode = parameter1
    )
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Nov 2009
    Posts
    18
    thank you!

    now it's working
    Last edited by tchiloh; 03-23-10 at 05:51.

  4. #4
    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:

    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

  5. #5
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    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
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  6. #6
    Join Date
    Nov 2009
    Posts
    18
    what is the value of a emty field.

    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

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try IS NULL

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    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();

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •