Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: SELECT problem

  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question SELECT problem

    hi,i have a prob here....for eg,
    SELECT name, birth, CURDATE(),
    -> (YEAR(CURDATE())-YEAR(birth))
    -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
    -> AS age
    -> FROM table;
    can i change the SQL statement above to INSERT statement....????it is bcoz i hav the prob when i jz use SELECT statement....is it possible to use the statement above n apply to INSERT statement????

    thank u

  • #2
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is this crazy language you speak? Where are all the vowels? This forum isn't an SMS, you don't have a character limit...

    Without seeing more details, I can only assume you're after something like:
    Code:
    INSERT INTO table(name, birth)
    VALUES ('John', '1976/10/23')

    I take no responsibility for the above nonsense.


    Left Justified

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry for any inconvenience....i mean this condition...
    -->(YEAR(CURDATE())-YEAR(birth))- (RIGHT(CURDATE(),5)<RIGHT(birth,5)) AS age
    can i put this condition combine with the INSERT statement....bcoz i hav found this example from Internet....but is using SELECT....i jz wan to ask is it possible to use the condition above(red color) combine with the INSERT statement???

    thank u

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Don't store that. Just store the year of birth. You use that type of query when you need to calculate if someone has already had a birthday or not this year.


  •  

    Posting Permissions

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