I'm working on an ongoing project in which I'm dealing with quotes and the database structure is not well organized and I can't make too many changes to the database schema to fix it.
In the database:
regular_quotes and premium_quotes are two tables. date/time, there is no column related to created_at, and there is no backup columnstoragedate/ timeTable 1
Regular quotes
id | name | quoteno | status | .....| ------------------------------------------ 1 | name1| RQ-909099 | pending | .....| 2 | name2| RQ-800099 | pending | .....| 3 | name3| RQ-965099 | approved | .....|
Table 2
premium_quotes
id | name | quoteno | status | .....| ------------------------------------------ 1 | name1| PQ-209099 | pending | .....| 2 | name2| PQ-300099 | pending | .....| 3 | name3| PQ-965099 | pending | .....|
What I did was:
recent_quote_metaid, quote_id, quote_type, created_at, updated_at, deleted_atrecent_quote_meta and use quote_idquote_id and quote_type and based on this I am getting and displaying the quotes accordingly But the situation is, they don't want me to make any changes to the database. And I don't think that can be done in the current scenario.
Is there a way to get the latest quotes for these tables? It can be regular_quotes or premium_quotes
Thanks!
Without any timestamp column, there is actually no way to determine which of the two tables has the latest quote entry. There are some tricks we can try, but your situation will determine whether they are trustworthy.
One way is that you can check if the IDs are assigned in order, and since you know the latest ID in both tables, you can compare them to determine which table has the latest quote. For example, if the latest
idin theregular_quotestable is3, and the latestidin theregular_quotestable > The premium_quotes table is5, and it can be concluded that thepremium_quotestable has the latest quotes.These will return the highest ID value in each table. You can compare these two values to determine which table has the latest quotes, with
idhaving the highest value.Ideally, you may want to tell an administrator to resolve this issue.
Hope this is useful to you.