SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    wuhan china
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question can this SQL work ??

    wo all know that when selecting data from database

    wo write "select * from database where id="

    in this sentence: (database is your database name ,id is one item in one of your table)

    can we use like this??

    "select * database where function(id)="

    in this way, we can select data more freely

    I have tried this method ,but it doesn't seems to work

    is any guy here who have a similar idea??

    please write your opinion here

    thank you

  2. #2
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never seen anything like this though you can dynamically insert into an SQL statement by parsing for a question mark for example ?

    Some examples of Java I've seen uses this approach, though are you referring to a mySQL function, or a PHP function btw ?

  3. #3
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by infoseek
    wo all know that when selecting data from database

    wo write "select * from database where id="

    in this sentence: (database is your database name ,id is one item in one of your table)

    can we use like this??

    "select * database where function(id)="

    in this way, we can select data more freely

    I have tried this method ,but it doesn't seems to work

    is any guy here who have a similar idea??

    please write your opinion here

    thank you
    don't take unnecessary shortcuts. they don't help speed, they do hinder readability, and they often don't work. try this:
    PHP Code:
    $new_var = function(id);
    $query "select * database where $new_var="
    also, for the record, 'database' above is the table, not the db

  4. #4
    Non-Member
    Join Date
    Aug 2002
    Location
    USA
    Posts
    544
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by infoseek
    "select * database where function(id)="
    That should work - for custom functions. Not Aggregates. In PostgreSQL anyway.

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    wuhan china
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Darchangel
    don't take unnecessary shortcuts. they don't help speed, they do hinder readability, and they often don't work. try this:
    PHP Code:
    $new_var = function(id);
    $query "select * database where $new_var="
    also, for the record, 'database' above is the table, not the db


    thanks for your reply , but I'm afraid you didn't quite follow me ,I mean the "id" is the one of the item in your one of your table , that is to say before you have select it from database ,you don't know its value , therefore how can we function it ???

  6. #6
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Raleigh, NC
    Posts
    783
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think i understand a little better. what exactly are you trying to find? what is your final goal?


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
  •