-2

we have a SQL table "ContactLot" in this table we have a column "contactTableName" and "creationDate", i'm tring to get all ContactLot after 2020-02-01 (here i can use creationDate column" and then i want to get some values from every table in contactTableName column, can you help me ? i'm using HeidiSQL (MySQL)

this is my request

SELECT COUNT(*) FROM ContactLot.contactLotTableName WHERE ContactLot.creationDate > '2020-02-01 00:00:00'

I know thise request is not correct but i put it just for exemple.

Thank you.

exemple of ContactLot table and contatactTableName column

  • 2
    SQL tables represent *unordered* sets, so please define what you mean by "after 2020-02-01". Also provide a database tag. – Gordon Linoff Jun 04 '20 at 12:14
  • for the DATE we have a column "creationDate" in ContactLot Table, so we can use WHERE clause to get all table after X date. – Brahim Djarallah Jun 04 '20 at 12:19
  • Could you provide which database engine you are using and put it in tags? – Leszek Mazur Jun 04 '20 at 12:20
  • [Why should I tag my DBMS](https://meta.stackoverflow.com/questions/388759/) –  Jun 04 '20 at 12:23
  • okey i did it, mysql with heidiSQL, thank you – Brahim Djarallah Jun 04 '20 at 12:25
  • Welcome to SO. Please see [Why should I provide an MCRE for what seems to me to be a very simple SQL query](http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query) – Strawberry Jun 04 '20 at 12:29

1 Answers1

0

You table alias is wrong. That seems to be about it. I would suggest:

SELECT COUNT(*) 
FROM ContactLot.contactLotTableName cl
WHERE cl.creationDate > '2020-02-01';

Note that "after 2020-02-01" is a bit misleading. This will get anything on that date, but not at midnight when the day begins. You probably want one of these conditions:

WHERE cl.creationDate >= '2020-02-01'

WHERE cl.creationDate >= '2020-02-02'
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • i had this response SELECT command denied to user **** but when i use the same request and i replace ContactLot.contactLotTableName with one of my tables i get the results... – Brahim Djarallah Jun 04 '20 at 13:47