SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: mysql function

  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql function

    Hi

    I have gone through MySQL functions .

    What I don't understand is where to use function . Can I call a function in SELECT query ?


    something like this ..

    SELECT COLUMN1 , COLUMN2 , myfunc(COLUMN3) from mytable

    Can you please tell if this is a valid syntax ? if not how to invoke a function in select query ?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    San Sebastian, Spain
    Posts
    93
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes this is the correct syntax. If you look at some of the string functions e.g. substring:

    Code:
    mysql> select substring('abc',1,2);
    +----------------------+
    | substring('abc',1,2) |
    +----------------------+
    | ab                   | 
    +----------------------+
    1 row in set (0.00 sec)
    This could easily take a field from a table as a parameter.

  3. #3
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. This is helpful


Bookmarks

Posting Permissions

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