prakash Posted April 8, 2008 Share Posted April 8, 2008 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 More sharing options...
Barand Posted April 8, 2008 Share Posted April 8, 2008 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 ..." ? Link to comment https://forums.phpfreaks.com/topic/100232-need-help-on-php-mysql-query/#findComment-512505 Share on other sites More sharing options...
prakash Posted April 8, 2008 Author Share Posted April 8, 2008 Have you tried "SELECT DISTINCT ..." ? yes using DISTINCT I can get the individual data but how can get non-repeated data when data from both table combined and in order also Link to comment https://forums.phpfreaks.com/topic/100232-need-help-on-php-mysql-query/#findComment-512507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.