Search in Mysql...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    Search in Mysql...

    Hello...
    i have a table which contains a column named "ask" and a column named
    "per"...
    my think is that i want to search in "ask" and echo the data stored in "per"
    for this entry...
    How do i do this?
    Thanx in advance!
    JBK


  • Soren

    #2
    Re: Search in Mysql...

    SELECT * FROM table WHERE ask = 'something'

    And then echo the per row.

    But this is really a very simple question if you know anything about
    PHP and MySQL which I gather you don't.

    Do a search on Google for "php mysql tutorial" and you ahould find your
    answer.

    --------------------------

    Soren Beck
    Costa Tropical Internet
    English-speaking community website for the Costa Tropical area. Free business directory, classifieds, forum, event calendar, news and more


    jbk@ewebs.gr wrote:
    Hello...
    i have a table which contains a column named "ask" and a column named
    "per"...
    my think is that i want to search in "ask" and echo the data stored in "per"
    for this entry...
    How do i do this?
    Thanx in advance!
    JBK

    Comment

    • Ivan Marsh

      #3
      Re: Search in Mysql...

      On Fri, 11 Aug 2006 19:09:52 +0300, jbk wrote:
      Hello...
      i have a table which contains a column named "ask" and a column named
      "per"...
      my think is that i want to search in "ask" and echo the data stored in "per"
      for this entry...
      How do i do this?
      Thanx in advance!
      JBK
      select per from tablename where ask = $somevariable;

      --
      The USA Patriot Act is the most unpatriotic act in American history.
      Feingold-Obama '08 - Because the Constitution isn't history,
      It's the law.

      Comment

      • Guest's Avatar

        #4
        Re: Search in Mysql...

        Thanx...
        I am really new to PHP and Mysql...
        Anyway, thanx again!
        ? "Soren" <sorenbeck@gmai l.com?????? ??? ??????
        news:1155315494 .867819.184880@ 74g2000cwt.goog legroups.com...
        SELECT * FROM table WHERE ask = 'something'
        >
        And then echo the per row.
        >
        But this is really a very simple question if you know anything about
        PHP and MySQL which I gather you don't.
        >
        Do a search on Google for "php mysql tutorial" and you ahould find your
        answer.
        >
        --------------------------
        >
        Soren Beck
        Costa Tropical Internet
        English-speaking community website for the Costa Tropical area. Free business directory, classifieds, forum, event calendar, news and more

        >
        jbk@ewebs.gr wrote:
        >Hello...
        >i have a table which contains a column named "ask" and a column named
        >"per"...
        >my think is that i want to search in "ask" and echo the data stored in
        >"per"
        >for this entry...
        >How do i do this?
        >Thanx in advance!
        >JBK
        >

        Comment

        • Robert

          #5
          Re: Search in Mysql...

          Searching in MySQL can be tricky. If you are wanting to search in MySQL
          the correct code examles are true:

          (1) Search with wildcards (note "s" in wildcard)
          SELECT * FROM table WHERE col LIKE '%search%'
          -or-
          SELECT DISTINCT * FROM table WHERE col LIKE '%search%'

          Notice the % (percent sign), this means it will match "search" with
          ANYTHING before -OR- after the search term. But if you only want to
          search AFTER the term, you would only use the % sign AFTER. Example:
          SELECT * FROM table WHERE col LIKE 'search%'

          Same for searching BEFORE the search term. Example:
          SELECT * FROM table WHERE col LIKE '%search'
          -- This will pull anything that starts with * (wildcard) and includes
          "search" after it.

          Theres also another way to search by using the wildcard (notice: no
          "s") search.
          It's somewhat like the first explaination, but different.

          SELECT * FROM table WHERE col LIKE 'somthing_'
          Notice the _ (underscore) -- This means MySQL will get everything from
          the term "something" plus anything after "something" -- for example:
          "somethings " will be selected as found in the search. The _ is a
          wildcard modifier which will tell MySQL how many wildcards it will
          search. For example, if you used 3 underscores ___ it will look for the
          search term then anything that has up to 3 wildcards. For example:
          SELECT * FROM table WHERE col LIKE 'something___'

          You can also use it from a starting point. For example:
          SELECT * FROM table WHERE col LIKE '___something'
          This is basically the samething as 'something___' but it will get up to
          3 wildcards BEFORE the search term.

          Helpful? If you're confused you can always visit (MySQL 5+)
          http://mysql.com/doc/refman/5.0/en/select.html -or- (MySQL 4+)


          Hope this helps, -Rob


          jbk@ewebs.gr wrote:
          Hello...
          i have a table which contains a column named "ask" and a column named
          "per"...
          my think is that i want to search in "ask" and echo the data stored in "per"
          for this entry...
          How do i do this?
          Thanx in advance!
          JBK

          Comment

          Working...