Jump to content

need help on php-mysql query


prakash

Recommended Posts

I have two table as below

CREATE TABLE tbl1 (sn int(11) NOT NULL auto_increment, date_year int(4) NOT NULL, date_month text NOT NULL, date_day int(2) NOT NULL, data1 text NOT NULL, PRIMARY KEY (sn));

 

CREATE TABLE tbl2 (sn int(11) NOT NULL auto_increment, date_year int(4) NOT NULL, date_month text NOT NULL, date_day int(2) NOT NULL, data1 text NOT NULL, PRIMARY KEY (sn));

 

on the table year is stored as numeric values like (2008)

month is stored as short textual representation of 3 letters (Jan)

and day stored as numeric values without leading zeros (1)

 

now I need to get distinct values of date_year, date_month and date_day from both table and listed on <option> with repeating values

 

I have tried little bit but can't sort it out how to get non-repeated data from both table

 

please help me to get rid out of this problem.

Link to comment
https://forums.phpfreaks.com/topic/100232-need-help-on-php-mysql-query/
Share on other sites

MySQL provides a DATE type. It's worth using rather than inventing an alternative way to store dates.

 

And it is permitted (and preferred) to use newlines in an SQL statement

 

CREATE TABLE tbl1 (
    sn int(11) NOT NULL auto_increment, 
    date_year int(4) NOT NULL, 
    date_month text NOT NULL, 
    date_day int(2) NOT NULL, 
    data1 text NOT NULL, 
    PRIMARY KEY (sn)
);

 

Have you tried "SELECT DISTINCT ..." ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.