how to get current month data from two tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    how to get current month data from two tables

    Hi everyone,

    I need to get the records for the current month from two tables. I know how to do it with one table. im using the following query for it:
    Code:
    SELECT * FROM mytable  WHERE YEAR(date_column) = YEAR(CURDATE()) AND MONTH(date_column) = MONTH(CURDATE())
    This is giving me records for the one table only. but how i can get records from two tables?

    please tell me.

    Thanking you.

    Faisal
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Are these tables related?

    Comment

    • mfaisalwarraich
      New Member
      • Oct 2007
      • 194

      #3
      no they are not related

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        You could use a UNION to join the records of two tables.

        MySQl UNION

        Comment

        • mfaisalwarraich
          New Member
          • Oct 2007
          • 194

          #5
          yeah UNION ALL worked for me :)

          Comment

          Working...