skip to Main Content

So i have a table that has multiple date time columns and i am trying to select certain records based on a certain date using

SELECT * FROM `posdata` WHERE `CommissionDate` >= '2019-01-01 00:00:00' 

the table structure

CREATE TABLE `posdata` (
  `ID` int(11) NOT NULL,
  `DISTYNAME` varchar(30) DEFAULT NULL,    
  `ENDCUST` varchar(75) DEFAULT NULL,
  `MFGCUST` varchar(50) DEFAULT NULL,
  `EXTPRICE` double DEFAULT NULL,  
  `POSPERIOD` datetime DEFAULT NULL,
  `PAYMENTDATE` date DEFAULT NULL,
  `QTY` double DEFAULT NULL,
  `UNITCOST` double DEFAULT NULL,
  `UNITPRICE` double DEFAULT NULL,
  `COMMISSION` double DEFAULT NULL,
  `SALESORDER` varchar(40) DEFAULT NULL,
  `PO` varchar(40) DEFAULT NULL,
  `POLineItem` varchar(20) DEFAULT NULL,
  `ENTRYDATE` datetime DEFAULT NULL,
  `AdjustedCommission` int(11) DEFAULT NULL,
  `CustomerPart-NO` varchar(50) DEFAULT NULL,
  `CommissionDate` datetime DEFAULT NULL,
  `EXTCOST` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `posdata`
  ADD PRIMARY KEY (`ID`),
  ADD KEY `CommissionDate` (`CommissionDate`);
ALTER TABLE `posdata` ADD FULLTEXT KEY `posdata_endcustomer_index` (`ENDCUST`);

a very weird thing happens, it returns all the fields as required, but the CommissionDate column has only ‘2019-01-01 00:00:00’ as the date. The actual CommissionDate column in the database has only ‘2016-01-01 00:00:00’ as the data.

I am using phpmyadmin to to run this query and have used the search filter on that and it always gives me the same result whether i run it thorough a php script or phpmyadmin. What am i doing wrong ?

2

Answers


  1. Chosen as BEST ANSWER

    the query was correct can some one delete this question !


  2. In your query SELECT * FROM 'posdata' means get all the fields from the table post data and then the next WHERE clause applies.If you only want to get the data from CommissionDate column

    Change Your Query to

    SELECT `CommissionDate` FROM `posdata`
    

    In the way you get the desired data.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search