View Full Version : Mysql select query
udaybabu
04-07-2014, 02:23 PM
Hi,
I need a query using tables.
Here i have some tables in my database table names like
test_20140405
test_20140406
test_20140407
test_20140408
in these tables same fields like feeprefix, feetime etc...
now here i am using php code..
from date: textbox with name of fromval
to date: textbox with name of toval
submit button
here my question is i slected to dates fromval is 20140405 and toval is 20140407, based on these values i need to get feeprefix, feetime from the test_values between fromval and toval?
help me out..
here my question is i slected to dates fromval is 20140405 and toval is 20140407, based on these values i need to get feeprefix, feetime from the test_values between fromval and toval?
That's not exactly a question…?
What code have you tried? What problem did you encounter — what happened, compared to what you expected to happen?
It will likely be necessary to share your database schema as well (e.g., the result from show create table `your-table-name-goes-here`). If you question has anything to do with your PHP and/or HTML, you will need to share that code also.
Your question is unclear.
Please provide more information, and be as specific as possible.
What do you want to accomplish? What have you already tried? What problems did you encounter?
Please be sure that you have included all relevant code and/or a link to the page in question.
udaybabu
04-08-2014, 09:58 AM
Hi,
Thanks for your reply..
I am not that much experienced person to explain but i will exp my point clearly.
I have a mysql db tables like
test_20140405(Date)
test_20140406(Date)
test_20140407(Date)
test_20140408(Date)
In these tables we have a common fields like feeprefix, feetime.
db part is over.. now from UI part.. i have a form with 2 fields like from date and to date and submit button.
now i selected from date and to date like 2014-04-05 and 2014-04-07 respectively and enter the submit button..
now my prob is take these input fileds and prepare a query to get feeprefix, feetime from the db tables.
here the date range is 2014-04-05 to 2014-04-07 so now we have db tables with dates..test_20140405 to test__20140408
according to give dates we have 3 db tables so we get feeprefix, feetime from these 3 tables..
I hope u got my point..
You must provide relevant code if you expect to get help. Making us guess will not help solve your problem.
In general terms, the date needs to be a field in the table, not its own table. It should also be a DATETIME (https://dev.mysql.com/doc/refman/5.7/en/datetime.html) field, and contain only the date (other info, like "test__" (if that is even needed), should be stored in other fields). This will allow you to search for records between given dates by using the BETWEEN (https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_between) operator.
I am not that much experienced person to explain but i will exp my point clearly.
That's just fine- that's not a problem. I explained (above (http://www.dynamicdrive.com/forums/showthread.php?76673-Mysql-select-query&p=306396#post306396)) how to find the info we need.
Again, if you want a more specific answer, show your database schema and the code you are using. You should, of course, obfuscate any private/sensitive information.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.