I have a table called data where I have multiple columns of multiple times, and the table columns are dynamic.
I need to display it in a table, so I do select * from data but when the date columns are displaying like this 2018-10-10T18:30:00.000Z but the type of the column is date.
Should I modify it and then display or it is because of something else?
Related
Is it mandatory to know the table name from which you want to fetch some data based on some criteria? For example, here I have a database with 20 tables containing the same columns, only different row data.
And I want to fetch some data, from outside, based on some criteria, without being able to know the table name. Is there some sort of query available, something like:
SELECT * FROM SOME TABLE WHERE ID = [randomnumber]
I've a list of records (in excel) which I want to lookup in SQL table to find their entry date in table.
For example I've name of 200 customers in an excel sheet which are also in my SQL table but there are many others as well. I want to compare those users in table and find their date of joining the table i.e the date they were added to the table.
Do you have any column such as "customer_id"? If not, create it in the tables as it will make it easier for you to select and join tables. You can use the alter table statement to add the new column. After adding the columns, join the tables and use the select statement to find the required record.
You must have a key to bind those data. Any other way can be dangerous linking these informations. Maybe, the way is adapt your application or excel to provide this bind between the data.
mysql query to find data entry not present in table for particular date
I wish to find particular fridays date whose entru is not present in the table
You can query the things that exist in the data. So to find missing dates, you can create a table with all dates in your desired date range and make a query which selects those dates that do not exists in your other table.
Say I have a simple mysql table containing a name field which is just a varchar. The name field contains a string of the following format. "channelname,unix_timestamp,unix_timestamp". e.g. "bbc1,123456789,123456889". I need to select all rows, where a channelname matches, and where a given timestamp falls within the range of the 2 timestamps. For example, given the timestamp 123456800, and the channelname 'bbc1' The above record should be selected.
How I would accomplish this is to first select all records with "name like 'bbc1,%' split out the two timestamp fields in the calling code, and filter the results there to those containing the given timestamp. Is there a better, more efficient way. My DB could have a very large number of records which match "name like 'bbc1,%'", and it's only expected to grow as time goes on.
I unfortunately don't have the ability to alter the table to add the two timestamp fields, the only thing I have to go on is that single name field. It's also possible that the name field may contain some arbitrary string not of the given format for some records, however all records which start with the given channel name should match this format.
I have a table with 21 columns and I need to find all column names that have a specific value in them. This goes beyond my knowledge of database querying.
If this is possible, how would I do this?
Do you need to find columns in which the name of the column contains a certain value or there exists a row in which the given column contains the given value?
In the first case you could try the show columns: http://dev.mysql.com/doc/refman/5.0/en/show-columns.html