SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search string Records

    Hello
    I would like to ask for help. I do not know how to write a query to a database that records marked I like the file shown http://www.panorama.vot.pl/table.jpg. I want to search for a string of records in col1 from col2 (highlight it wants and how it does not find that the lack of communication drew within. Number of records in col2 will increase or decrease. Thanks in advance for any answers.

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    Please paste your table structure on here in plain text so that everyone can read it in case you take that image down, plus I don't want to open that while at work.

  3. #3
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to search for a string of records in col1 from col2 (highlight it wants and how it does not find that the lack of communication drew within. Number of records in col2 will increase or decrease. Thanks in advance for any answers. table.jpg

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    So there is no "highlighting" in SQL. I'm also at a loss when trying to figure out what you want your final result to be out of that recordset.

  5. #5
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want find records from col2 in the same order in col1 . You can see that on picture http://www.panorama.vot.pl/table.jpg

  6. #6
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    So you want your end result to be
    col1
    -----
    1
    2
    3
    4
    5
    1
    2
    3
    4
    5

  7. #7
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, and will it possible in which id (of course if I have id column)

    id col1
    -----------
    1 1
    2 2
    3 3
    4 4
    5 5
    16 1
    17 2
    18 3
    19 4
    20 5

  8. #8
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what is your query for

    col1
    -------
    1
    2
    3
    4
    5
    1
    2
    3
    4
    5

  9. #9
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    I don't have one yet. Not sure I've seen one like this before. What sql server are you using? Also how large of a table are we talking about?

  10. #10
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm usigng MySQL server and table have one column with 2000 records and second column with flexible records (5-10).

  11. #11
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,330
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by dziabaa View Post
    I'm usigng MySQL server
    could you please run this query and post the results --
    Code:
    SHOW CREATE TABLE tablename
    where tablename is the name of your table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  12. #12
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CREATE TABLE `klikacz` (
    `id` int(50) NOT NULL AUTO_INCREMENT,
    `col1` varchar(50) CHARACTER SET latin2 NOT NULL,
    `col2` varchar(50) CHARACTER SET latin2 NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=utf8

  13. #13
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,330
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by dziabaa View Post
    ...and second column with flexible records (5-10).
    i do not understand this
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  14. #14
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,330
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by dziabaa View Post
    ...and how it does not find that the lack of communication drew within.
    i don't understand this, either
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •