in query, how can I compare string?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kirke

    in query, how can I compare string?

    Hi I wanna put string in query "where" part.

    For example,

    $sql="select VEHICLE
    FROM database
    WHERE MECHANIC =BRIAN
    ";

    like above, "mechanic" column is filled with strings. Then how can I
    write "where" part?
    Above query does not work.
    Thanks.

  • Erland Sommarskog

    #2
    Re: in query, how can I compare string?

    kirke (hinkyeol@gmail .com) writes:
    Hi I wanna put string in query "where" part.
    >
    For example,
    >
    $sql="select VEHICLE
    FROM database
    WHERE MECHANIC =BRIAN
    ";
    >
    like above, "mechanic" column is filled with strings. Then how can I
    write "where" part?
    Above query does not work.
    Does this:

    $sql="select VEHICLE FROM database WHERE MECHANIC = 'BRIAN';

    Or what do you mean with "filled with strings"?


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server 2005 at

    Books Online for SQL Server 2000 at

    Comment

    • Ed Murphy

      #3
      Re: in query, how can I compare string?

      Erland Sommarskog wrote:
      kirke (hinkyeol@gmail .com) writes:
      >Hi I wanna put string in query "where" part.
      >>
      >For example,
      >>
      >$sql="select VEHICLE
      >FROM database
      >WHERE MECHANIC =BRIAN
      >";
      >>
      >like above, "mechanic" column is filled with strings. Then how can I
      >write "where" part?
      >Above query does not work.
      >
      Does this:
      >
      $sql="select VEHICLE FROM database WHERE MECHANIC = 'BRIAN';
      Should be
      $sql="select VEHICLE FROM database WHERE MECHANIC = 'BRIAN'";

      (Normally, I would assume that the user would figure this out,
      but in this case the original poster appears to still be at the
      stage of struggling with the basics.)

      Comment

      Working...