•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 374,142 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,472 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 572 | Replies: 4
![]() |
Here is an example... could you try to be more specific?
This will select records with an in_date of '%-03-18' or out_date of '%-04-20':
This will select records with an in_date of '%-03-18' or out_date of '%-04-20':
SELECT * FROM table WHERE in_date LIKE '%-03-18' OR out_date like '%-04-20'
•
•
Join Date: May 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
If by 'pair up' you mean that you want them to appear in the same row, I think the approach would be to join the table to itself.
So if you had a table like:
And you want a result like:
A query like this should do it:
So if you had a table like:
id description linkid 1 item 1 3 2 item 2 1 3 item 3 2
And you want a result like:
leftdescription rightdescription item 2 item 1 item 3 item 2 item 1 item 3
A query like this should do it:
MySQL Syntax (Toggle Plain Text)
CREATE TABLE if NOT EXISTS link2myself(id INT, description VARCHAR(6), linkid INT); INSERT INTO link2myself(id,description, linkid) SELECT 1, 'item 1', 3 UNION SELECT 2, 'item 2', 1 UNION SELECT 3,'item 3', 2; SELECT me.description leftdescription, otherme.description rightdescription FROM link2myself me JOIN link2myself otherme on me.linkid=otherme.id; DROP TABLE link2myself;
•
•
Join Date: May 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
Just as a note, the 'CREATE TABLE' is used to create a sample table with some sample data. It has no relation to the solution. In practical usage, you would use the table you already have.
Also, if you want to string concatenate some rows you can use the aggregate function group_concat(). But if you want them to appear as separate columns, use join.
Also, if you want to string concatenate some rows you can use the aggregate function group_concat(). But if you want them to appear as separate columns, use join.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- Open In New Window Php (PHP)
- home work help funcations and arry issues (C)
- samba 3.0.22 on solaris 9 (Getting Started and Choosing a Distro)
- Need some help with min/max in arrays (C++)
- max cpu speed on hp ze4000-5000 serious? (Motherboards, CPUs and RAM)
- Max and Min values from a group of numbers (C++)
- Page hangs or displays connection pooling max size error (ASP.NET)
- This ought to be simple - extra spaces (PHP)
- Max Payne 2 and Direct X 9 (Monitors, Displays and Video Cards)
- never taught how to show the VAT of a total. I know that u divide by 1.175 (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: Is difficult for me solve this query! please help! :(
- Next Thread: myisam innodb fulltext normalization question


Linear Mode