Hi all,

I wonder if it is possible that someone can drop me a code or something on this particular problem which I am currently dealing with.

in_date out_date
18/03 30/04
20/04

So how am i supposed to pair up 30/04 and 20/04 as 1 pair and show it up in the table? Many thanx in advance

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':

SELECT * 
FROM table 
WHERE in_date LIKE '%-03-18' 
OR out_date like '%-04-20'

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:

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:

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;

Lets say you really dont want to create a table and you dont want to join tables but concatenating two records from one table instead...........

I think you need to be more specific coz what u said above is completely unclear

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.