More Questions About The Mysteries Of Time And Dates In Mysql
part of a query I am running goes as follows:
floor(sum(unix_timestamp(dtp.endtime)-unix_timestamp(dtp.starttime))/60) as total.....group by dtp.activityno
dtp.endtime and dtp.starttime are both datetime fields.
I am saving the result into a temporary table and what it gives me is the total number of minutes spent on the selected activitynos...
My question is: if a result from this query is for example 123 (and 123 minutes is the correct number of minutes-2 hrs and 3 minutes) how can I show this result as a date field in MySQL? that is as 02:03:00?
I tried setting the field type to date when creating the temporary table but that just made a mess of the actual number of minutes.
Anybody have any ideas?
View Complete Forum Thread with Replies
Related Forum Messages:
- Elapsed Time Between Two Dates
- Storing Dates And Time To Database
- Comparing Dates Y, M, D , Time In Sql Query
- Find Time Difference Between Two Dates
- Converting MS Access Dates To MySQL Dates During LOAD DATA INPUT ?
- 2 Mysql Questions
- New To Mysql. 2 Questions
- MySQL Questions
- Questions About Mysql
- Update String Dates Into Mysql Dates
- MSSQL Dates -> MySQL Dates Automatically?
- MySQL Capabilities Questions
- Mysql Insert Questions
- General MySQL Questions
- Simple MySQL Questions
- PHP/MySQL Sorting By Date & Time (using Non Military Time)
- Follow Up Questions On EXPLAIN Output (was "mysql Help")
- Select Into Two Tables, One With Dates Second With Events For Those Dates
- Error 127, Some Questions
- BIGINT Questions
- Constraints Questions
- Max Questions Reached
- Version Questions
- Installing Questions
- DB Relationship Questions
- Some Questions Regarding My Database Project
- InnoDB Table Questions
- Questions About Innodb Locks
- Database Design Questions
- A Few Questions About Chat Applications
- More Database Structure Questions
- Blog Categories Questions
- List All Dates Between 2 Diff Dates
- Dates Pre 1970 And Dates After 2050
- List All The Dates Between 2 Given Dates Using SELECT
- Stroring Dates Perior To 1 AD, BC Dates
- How To List All Missing Dates Between 2 Dates
- Dates, Dates, Dates - Syntax Help Please!
- INSERT INTO ... SELECT (...) Performance Questions
- Primary/Foreign Key EER Diagram Questions
- Stock Quote Database Questions
- Questions Regarding My Supertype/subtype Setup
- 10 Random Encoding And Collation Questions
- Questions About Pagination Query, Never Been Asked, Must See! :)
- Creating Databse To Insert Multiple Choice Questions
- Using Dates In PHP + MySQL
- Querying Dates In Mysql
- Importing Dates Into MYSQL
Elapsed Time Between Two Dates
I need the elapsed time between posting of an item and the current local date. I have a table, with timestamp, want to pull each entry and calculate the elapsed time for each entry. ie, how old is this posting?
View Replies !
Storing Dates And Time To Database
I was wondering how to store this date into the database: Friday, August 28, 2015 and this time: 8:00PM I have one field that collects the date and another for the time.. Im looking to store them in this format, 0000-00-00 00:00:00.. Is there some way to turn this date "Friday, August 28, 2015" into this "0000-00-00 00:00:00" so it will be inserted into the database using DATETIME??
View Replies !
Comparing Dates Y, M, D , Time In Sql Query
ok.. ive finally got my nice little calender setup to output my dates now how do i query my database for example ive got 2 variables $startdate = 2006-1-1 00:00:01 $enddate = 2006-1-1 23:59:59 these represent the 1st and last second of the first of january 2006 i have a cell in my table (table called challenges) ( cell called time) that contains a date in the same format for each entry how do i get all the entries between the start time and the end time.. can i use less than < and more than > as these are not really integar values the column type is datetime but there is also another column of type datetime
View Replies !
Find Time Difference Between Two Dates
I have the following MySQL query and I would like to find the time difference in days, mins, hours between the current time and the "end_date" field (which is a datetime filed). PHP Code: select auctions.end_date,domains.* from domains left join auctions on auctions.domain_id = domains.id where end_date > now() and active='1' order by end_date desc limit 10
View Replies !
Converting MS Access Dates To MySQL Dates During LOAD DATA INPUT ?
My insert code is below. The MySQL server is on my local machine and is version 4.1.22. I am exporting from an access table with 6 fields to a mysql table with those 6 plus 5 more fields. The main problem I am having SO FAR, is converting dates. The data file dates are formated like: 2/2/2006 0:00:00, 12/20/2006 9:22:05 Any ideas how to format those into mysql friendly dates? Also, how do I convert currency fields in the load data process? I know you use SET by what kind of formula? =========================================== LOAD DATA INFILE 'C:Documents and Settingspath_to_filedata.txt' INTO TABLE auto (field2, field3, field4, field5, currency_field6, field7, date_field8, date_field9) SET id = MD5(UUID()) FIELDS TERMINATED BY ',' LINES TERMINATED BY ' '
View Replies !
2 Mysql Questions
Got 2 quick questions that i hope some of you people out there can help me with. 1) I am currently running mysql 5.0 alpha on my server but a few programs that worked on mysql 4 won't run properly on 5.0, so is it possible to change some settings in mysql 5 so its backward compatible with mysql 4 programs?` 2) What is the easiest way of upgrading from 5.0 to 5.0.1 under redhed linux or webmin without loosing the data in database?
View Replies !
New To Mysql. 2 Questions
I am new to mySQL and I have 2 questions: 1. Everytime I login to mySQL: machine 21:06:32 ~ $ mysql -u root -p Enter password: It asks me for password. Since I didn't set a password for root when I installed mySQL, I can just hit Enter and I will be login. This seems silly so is there a way to disable the prompt so I am automatically login without hitting Enter? 2. I want to create a user account with only SELECT privilege from everywhere (like from other hosts). How can I do that? Will the following work: GRANT SELECT PRIVILEGES ON mydb.* TO 'readonly'@'*' IDENTIFIED by 'password' Do I need to create the 'readonly' user first? Or will the above automatically create the 'readonly' user if it does not already exists?
View Replies !
MySQL Questions
I have a few SQL questions..i was hoping you guys could help with! Example: I have 3 tables, one which is a series of id's, and the other 2 which contain data: talbe: contacts_pool (just a linking table with id's) id, pool_id, contacts_id .. table: client id, name, pool_id, contact_id .. (every client has a main contact: contact_id and also a pool of contacts: sales, support etc) table: contacts id, name, address, tel, fax etc.. 1. I want to run a query to show all clients that do NOT have an entry in the contacts pool (pool_id). So far, I havent managed to do this...understandably the following returns *all* values that do not match, clearly not what i want: "select * from clients, contacts_pool WHERE clients.contacts_pool != contacts_pool.pool_id;" So I think I would be looking at finding the ones that DO match, and somehow accessing remaining rows..any ideas? 2. From the results set, i'd like to be able to use the results (in the same way as $x = mysql_fetch_array then $x['id'] in php), but in the sql query window)..is this possible? 3. Also, after putting the results in an array (mysql_fetch_array) how can you differenciate between two fields of the same name, but from different tables? $x['tablename.id'] doesnt work..is there a way to do this, i.e. to define exactly which id I want? A workaround would be to use in the query window: select id AS NEWid, but i want a cleaner way to do it.
View Replies !
Questions About Mysql
Iam a database engineer.I have a question for my neighbours who were experts in database engineering, Why don't the lists include MYSQL in the Subject header for mail sorting?
View Replies !
Update String Dates Into Mysql Dates
I've got a table that someone created with varchar fields for month, day, and year. I've added a DATE field to the table, and now I want to combine all three of these strings into one DATE and stick it into the DATE field. Once I've got this done, I can delete those three varchar fields and just have the nice DATE field. Here's the command I've tried in several variations but no luck--syntax errors every time: UPDATE SET OCR_Entry_Date = date_format(str_to_date(concat_ws('-', OCR_MM, OCR_DD , OCR_YYYY) ,"%b-%d-%Y"), "%m-%d-%Y") WHERE OCR_YYYY = '1974' OCR_Entry_Date is a DATE field and the others are the varchar fields. My logic is basically: 1. concatenate the separate field values into a single string 2. convert the string into a date 3. format the date in the way I'd like it in the table
View Replies !
MSSQL Dates -> MySQL Dates Automatically?
We're using data feeds that were originally meant for MS SQL and the dates in the data feed (tab delimited text files) are formated like: Oct 21 2007 In MySQL, the date fields are formatted as datetime fields and when we do an import the dates all come through as 0000-00-00 00:00:00. We're importing using the MySQL "LOAD DATA LOCAL INFILE" command and just dumping the text files right into freshly truncated tables. Is there a way when loading the files to find and replace the dates maybe? Can MySQL convert the dates? I have a shell script downloading an archive and uncompressing, then it runs a PHP script that loops through the files runningt he LOAD DATA command. Any advice would be appreciated... I'm just looking for the easiest (and least server-intensive) way to get the date issue fixed. We've already tried begging the vendor but they're not yet ready to start supporting other date formats (even though their MS SQL db can output a date format friendly to MySQL). Thanks!
View Replies !
MySQL Capabilities Questions
I have a couple questions on the capabilities of MySQL. I have not had to go over the million row mark before in a table, and im surious how it stacks up. Im talking between 20-40 million rows of data, in one table, and the same number of rows in another table, containing the text of the pages that the first table contains. On this second table i will be creating a full text index on the contents for the use of full text searching, which i intend to implement on this table as well. has anyone dealt with this sort of beast before? and if so what kind of performance did you see? This will be on two servers, one is in the office, 4 cpus, 4 gb ram, and a couple TB's in raid-5 running on win2000 advanced server ( i know i know), the other server is signifigantly faster across the board, running Solaris.
View Replies !
Mysql Insert Questions
I want to insert data to a new table from an existing table, but I also want to enter a couple of new fields I have this query: INSERT INTO table1 ('field1,'field2') SELECT 'field1','field2' from table2 I want to have something like INSERT INTO table1 ('field1,'field2','field3','field4') SELECT 'field1','field2' from table2 , 'new value for field3','new value for field4' Is it possible, if so, what is the correct syntax?
View Replies !
General MySQL Questions
Im working on a project that involves table full of domains and I wanted to do a search script which searches those domain names based on certain criteria. I have just a general sql question list so if you would be so kind just to give rough simple queries on how to do them or toss me a link or two that I could read up about it. Example 1: Domain: domaintools.com I figured to search the domain for a word match I would use like? Select * from table where domain like='%domain%' Example 2: Domain: domain-tools.com I am trying to figure out some way to search for all domains where a - is not present, not sure how to do this one. Example 3: Domain: abc.com Domain: abcabc.com I am trying to figure out some way to return results based on there length I am not sure how to count in sql to return the length. For example Select * from table where length(domain) > 8 Example 4: Domain: search4.com I am trying to figure out a way to return all results where a number is present or not present, no clue how to do this one. Basically just a general how to is what im looking for or any resources that could help me on this. Unfortunatly I havent a clue how to do queries like this so I have no Idea what to even start searching for.
View Replies !
Simple MySQL Questions
I have these two simple questions about MySQL: 1- If a column (id) in a MySQL table holds data of type mediumint (or other int types), when I do an SQL query do I have to put the id number between single quotes like id=õ' or just id=875 ? And the more stupid question : 2- When I do an UPDATE query, does the updated column have to be the same one that identifies the row (after WHERE in the query) to be updated? i.e. is the following query valid? UPDATE table_name SET col1=1 WHERE col2=10
View Replies !
PHP/MySQL Sorting By Date & Time (using Non Military Time)
This is probably a simple issue but I have searched online and can't find an answer. I am using PHP/MySQL and I guess the most intuitive would be to have three select boxes containing HOUR / MINUTE / AM,PM option. Then store the time into mysql using there functions so I can output the data sorting them all by date and time. All the examples I have seen are for military time only but I'm sure there has got to be a simple mysql function or php function that converts non military to military and a formatting function to display with the AM / PM. But I have not found it.
View Replies !
Follow Up Questions On EXPLAIN Output (was "mysql Help")
explain SELECT * FROM job JOIN job_postings ON (job.jobid = job_postings.jobid) JOIN companies ON companies.companyid = job.companyid WHERE job.jobid IN (16189,16188); +--------------+-------+-------------------+---------+---------+-------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +--------------+-------+-------------------+---------+---------+-------+------+-------------+ | job | const | PRIMARY,companyid | PRIMARY | 4 | const | 2 | | | companies | const | PRIMARY | PRIMARY | 4 | const | 2 | | | job_postings | ref | PRIMARY | PRIMARY | 4 | const | 8 | Using where | +--------------+-------+-------------------+---------+---------+-------+------+-------------+ 3 rows in set (0.00 sec) Follow Up Questions Explain any optimizations that can be made to the above query. How many rows will be analyzed by this query?
View Replies !
Error 127, Some Questions
We have several tables experiencing table error 127 quite often, sometimes several times per day. I have read the relevant posts recently, including http://www.mysql.com/doc/en/Repair.html Forgive me for my lack of technical expertise in these questions: 1) The SQL statements are all INSERTS (using all fields - see below for table structure), so is it possible, say when a client server goes down during an insert, that somehow the data only gets inserted "half-way"? 2) From other posts, it seems that one common column is a date or timestamp field. Could this be the problem? 3) There are no (very few - once a month for statistical reporting) selects done on the tables, so we don't know when the problem occurs, so is there a way to monitor the tables? 4) It only affects my tables with more than 10k-20k inserts per day. 5) Is moving to InnoDB a way to possible solve the above? 6) We occasionally experience "Mysql server has gone away" - due to network congestion, could this cause problems? Code:
View Replies !
BIGINT Questions
I have a few questions about using a bigint as primairy key. 1) Does it effect performance, compared using regular INT as key? 2) Can a bigint hold 20 charaters? -> BIGINT(20) 3) Someone told me it would only be usefull on a 64 bit cpu. Is that true?
View Replies !
Max Questions Reached
We've had a mysql database running for a few weeks now supporting a simple application. This morning, for the first time ever, I came in and found that the application was erroring out due to max questions reached error. [the value was set to (I think) the default value of 50K]. I'm wondering if anyone can give me a little guidance on what, excactly, constitutes a 'question' in this case. Is each 'question' a dedicated log in attempt to the database, successful or failed? Or does it represent more of a database ping ala tnsping ? The description reads 'Number of queries sent to the server', but I'm guessing that this does not represent actual select statements, there looks to be another place dedicated to tracking selects and it contains far fewer values than the Questions value. Also confusing me is that we shut down the server and stopped all applications that were touching it. None the less, after resurrection, if I log into MySqlAdministrator, the number of queries kicks up at approximately 3 / second. The only connection I show to the database is my Administrator session, but the number of queries just keeps rolling. Is it possible someone else on my network has started toggling the database? If so, will changing the password alleviate this problem?
View Replies !
Version Questions
My first question is about which version of MySQL I should download. The server my site is on is running version 3.23.49. I would like to install MySQL on my PC to learn with and to work on prior to uploading to my site. Do I need to load the same 3.23.49 version on my PC?
View Replies !
Installing Questions
I run some websites where i use php scripts to open connections to add and delete info from database tables. I use phpMyAdmin as my interface to the tables. However, all of that resides on my web hosting company. I would like to be able to test my php scripts with my database tables locally, and then ftp them to the website once they work (so I guess I would like a testing environment setup on my computer). I know I would need to install mySQL and PHP on my computer, but would I need to intall Apache? Could somebody please tell me what I would need to install on my computer in able to run these scripts without having to ftp them to the internet everytime. I also plan on using Navicat as my Administrative Interface for mySQL.
View Replies !
DB Relationship Questions
I'm trying to set a Primary Key / Foreign Key relation using phpMyAdmin. 1. I assume that the Foreign Key is a Primary Key in its own table, and that really the relationship is between to Primary Keys, one that behaves as a Foreign Key. Is that correct? 2. It seems that if I select a table, I can then select 'Relation view'. That's where I seem to define this relation. Do I define it from the table that has the primary key, or from the table that has the foreign key? Code:
View Replies !
Some Questions Regarding My Database Project
I actually have a couple of questions regarding this project. First, I have a pretty good understanding of SQL code. I use to work with dBase III and IV. I now work with Access 97 and 2000 and can do simple Query designs. I have a text file that is about 915mb and consists of records that are fixed in length of 331 characters. There are no records delimiters 1. Does anyone know of a good text editor that I can use to insert a carriage return every 331 spaces? 2. I more familiar woth Access, but can Access handle nearly 2.75 million records? 3. Can MySql handle 2.75million records?
View Replies !
InnoDB Table Questions
I have two questions 1) is there restrictions on how many InnoDB tables you can create in a single mysql database? & is there a configuration I should work on before creating the tables? 2) I was trying to create one table and it refuses to create properly and I cannot see what is wrong with the code. maybe someone could help me out, [MYSQL]CREATE TABLE `models` ( `models` varchar(25) NOT NULL, `created_by` int(6) NOT NULL, `creation_date` datetime NOT NULL, PRIMARY KEY (`models`), INDEX (`created_by`), FOREIGN KEY (`created_by`) REFERENCES users(`users_id`) ON UPDATE CASCADE ON DELETE RESTRICT, )ENGINE=InnoDB; [/MYSQL]
View Replies !
Database Design Questions
I have 2 questions: 1st How many records can you store in the mysql table and database before you slow it down?(Im not referring about the web server storage) 2nd Having a table of people(contact info) data, is it bad database design to create 50 tables(one for each state) in one database to hold the data. If I can I think it would be fast for the searching of peopleās info. You can search one state instead of all 50(if you known what state you want).
View Replies !
A Few Questions About Chat Applications
I'm writing a chat app at the moment and it will likely have many rooms(possibly 100). I'm wondering if it would be best to use XML or mysql? If mysql, should i make one large table to hold the message stack for all the rooms or seperate tables for each room? all data within these tables is temporary so it will never be large.. would it be best to use MEMORY tables in this case?
View Replies !
More Database Structure Questions
i have a site that has products in categories. products have only 1 category. categories have unlimited sub-categories and have a self join on the categories table. categories can contain products, sub-categories or both. i also have merchants for each product. finally, a user can have a product list (list of products they have selected). A user can select 1,000's of products (this is not a shopping cart). when a user is browsing the categories, merchants and products, i want them to be able to filter their results by merchant, category or if the product is in their list. what i have so far (see below) is working but i want to know if this is the best way to deal with the problem and if it has potential scalability issues if i were to make more filters based on for example, brand or something else related to the product. cat2merchant this table allows me to track the categories a merchant's products exist in because some categories don't have products. more info here. this table would contain a row for every category and sub-category that the product exists in. category_id merchant_id categories id name parent productlist2product this keeps track of which products the user has added to their product list associated with their product list id (another table) productlist_id product_id merchants id name products id name merchant_id category_id cat2productlist2merchant this table helps me to filter results if user wants to just view all cats and merchants that contain their selected products. also, if a product exists here: cat1 > subcat2 > subcat3 > product, this table would have 4 rows (1 for each category). category_id productlist_id merchant_id I have considered combining the cat2productlist2merchant table with the productlist2product table but then that table would be filled with some empty product_id's. i've also considered making a table for each relationship a productlist_id has with other filterable tables such as merchants, categories (possibly brands).
View Replies !
Blog Categories Questions
I'm working on a blog and decided that I wanted to incorporate categories as well. I have been searching around on the forums and found several people are wanting the same type of thing to a point. My question is what if I wanted categories for blog posts but only wanted a blog post to be related to one category? I noticed that alot of others want the opposite but in my case I only want the former. So do i need to still use this type of mysql table scheme? blogpost (id ...) blogcategories(blogid, categoryid) categories(id,name) Or is there something alot simpler in my case or should I still use the above example?
View Replies !
List All Dates Between 2 Diff Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.
View Replies !
Dates Pre 1970 And Dates After 2050
i have MySQL version: 4.1.16-nt, when i try to insert a date pre 1970 or after 2050 into a timestamp field, the date is stored as all 0's, how can i save a date pre 1970 and after 2050 into a mysql field?
View Replies !
List All The Dates Between 2 Given Dates Using SELECT
how I can list all the dates between 2 dates (inclusive) using SELECT sql statement in mysql? I have a member table with the following columns: id int autoincrement name varchar(40) join_date date I want the following output (date, count of members joined on that date): 1 April 2009...... (2 members joined) 2 April 2009...... (0 members joined) 3 April 2009...... (3 members joined) .....so on ...upto 30 April 2009.....(1 members joined) For the above output I need the SQL command that is valid in mysql. Is there anyone who can produce the above result with a single SELECT command. Please don't suggest that is possible using php for loop or creating a mysqlorary table first and then inserting all the dates into it. Then make a join between mysql table and members table using date as GROUP by column etc. etc. I know this is possible using some user variables as I searched through the various SQL tutorial sites. But I am unable to figure out how I can produce a list of all dates between 2 given dates.
View Replies !
Stroring Dates Perior To 1 AD, BC Dates
I need to store some dates that can be BC, However I received a problem indicating Incorrect Datetime. I have read the documentation, and it says that Date&DateTime types can store from 1000-9999 AD, and Timestamp stores less year ranges. What other options do I have to store dates before 1000 AD !
View Replies !
How To List All Missing Dates Between 2 Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.
View Replies !
Dates, Dates, Dates - Syntax Help Please!
OK, I have a MySQL table which contains, among others, a field called date which stores dates in the format YYYY-MM-DD HH:MM:SS. What I'd like to do is select a list of all the months present (without repetition), preferably in the format YYYY-mm
View Replies !
INSERT INTO ... SELECT (...) Performance Questions
Using version: 4.0.18-Max-log We're getting some fairly poor performance when doing an INSERT INTO temp_table ... SELECT (...). The SELECT is grabbing 2K row chunks from its table, so the problem is not that the query results are so monstrous that it's just taking that long to gather them all. The problem appears to be one of IO. When an INSERT...SELECT is run, the SELECT part of the query is run first and those results saved in a temporary table. Then the contents of that temporary table are inserted into its final destination, which in our case *also* happens to be a temporary table. All of this table reading and writing is causing things to drag. Unfortunately I don't have our MySQL variables handy or our hardware specs. But I can get them in fairly short order either is needed. I do know that our hardware is < 6 months old and has a few gig of RAM. The discs, if I recall, are a RAID array but off the top of my head I don't know which flavor of RAID. Our questions: 1) Why does MySQL write to a separate temp table when the destination table is already a temp? 2) Is there some way to make the results of the SELECT write directly to the destination table (be it temporary or not)? 3) Are there any other suggestions for resolving this performance problem? Maybe there's a variable which at least will force the SELECT to write to a TEMPORARY HEAP table instead and avoid the extra disc IO? --V. M. Brasseur Software/Database Engineer iPost http://www.ipost.com
View Replies !
Primary/Foreign Key EER Diagram Questions
I am migrating from MS Access to MySQL (TONS faster, not to mention the usefulness of triggers). Well, I am running into problems with the way MS Access lets you design and the way MySQL designs tables. I test the joins and relationships with an ODBC Connection and linking the tables from within MS Access to my MySQL database. My question is within the PK-FK relationships. I usually would have one UNIQUE/Auto-Incremented id being created for most tables. However, when I create this type of relationship with certain tables I am unable to produce a truly enforced one-to-many relationship. I am attaching the photo of the relationships I am concerned with presently. Customer 1:N Customer_Model Customer_Model 1:N Customer_Model_Detail Customer_Model requires a UNIQUE index between Customer_id and Custom_Name, but I don't think that needs to be the PK for the table. I believe it would be simpler if I could generate a PK with an Auto-Increment option as this would solve my issue of having both [Custom_Name] and [Custom_id] as FK within Customer_Model_Detail. When I do as described above with the Auto Increment PK, MS Access will not recognize the relationship between PK [Customer.Customer_id] and FK [Customer_Model.Customer_id] and instead of saying 'One-to-Many' within MS Access it shows as 'Indeterminate' However, the relationship PK [Model_List.Model_List_id] and FK [Customer_Model_Detail.Model_List_id] always shows up as "One-to-Many" within MS Access.
View Replies !
Stock Quote Database Questions
I want to create an application which will collect the daily stock quotes everyday and also i will want to maintain historic price for every symbol. there are about 6000 symbols.
View Replies !
Questions Regarding My Supertype/subtype Setup
I'm doing a supertype/substype setup with one table (opposed to children tables) by using a row type column and allowing columns to contain nothing if they do not apply to that rows type. Should I be storing null for the columns which do not apply or something other? I am also wondering about the space my table will take up and any speed issues. The table will have about 20 columns with the majority of the time having data in about 15 columns.
View Replies !
10 Random Encoding And Collation Questions
I have some random encoding and collation questions I feel I need to ask so I call fill in some gaps in my knowledge. Most of them relate to MySQL so I thought this would be the best place for them. If you could help even with one it would be greatly appreciated: 1) What's the difference between the utf8_general_ci and the utf8_unicode_ci collations and are there any advantages to either? 2) Is there a way (In PHPMyAdmin or other) to convert a db along with all its tables, columns and data from one charset/collation to another without having to change each one individually? 3) Is there an easy way to tell what character set a server is sending? 4) What happens if the data in the db uses one encoding and the server is sending another? 5) What happens if a document is saved in one encoding and the server is sending another? 6) What happens if document is saved in one encoding but the db uses another? Am I right in thinking the following: 7) If you create a db without specifying a charset/collation, the default set will be used which is normally ISO-8859-1 with the Swedish collation. 8) All tables and text based columns created within this db will then use the default collation. 9) If you did specify a charset/collation for the db then all tables and text based columns created within it would use this same set without the need to specify it again. 10) If you changed the charset/collation for the db, this would only affect the db itself and not the tables and columns within it. Meaning that new tables would use the new set but existing ones would carry on using the old one.
View Replies !
Questions About Pagination Query, Never Been Asked, Must See! :)
My thread title is like a marketplace thread, eh? just an intermezzo Okay, to the problem: In a pagination code we need to fetch total rows first, for example using this query: SELECT COUNT(*) FROM table WHERE somefilter then, we do a query again to get the real data with a limit: SELECT * FROM table WHERE somefilter ORDER BY order LIMIT start, rows My questions: 1. I read that COUNT(*) is very fast because it pulls the count values right from table info (I don't know where mySQL saving this), is it correct? and is it still correct if there's a where condition like the query above? 2. Referring to http://dev.mysql.com/doc/refman/4.1/...functions.html, I want to use SQL_CALC_FOUND_ROWS to optimize the 2 queries into 1, but I read on the comment, someone says: Quote: Be aware that using SQL_CALC_FOUND_ROWS and FOUND_ROWS() disables ORDER BY ... LIMIT optimizations So is it true? I assume if there's no optimization for ORDER BY then the query will go slow. 3. Referring to http://php.net/mysql_num_rows on first note (by Typer85 at gmail dot com), there's an issue if we use SQL_CALC_FOUND_ROWS and FOUND_ROWS() : Quote: If two different requests come in through PHP, your going to run into problems. Note than when I mean request, I mean two different clients requesting your PHP page. --------------- Request 1: --------------- Execute: SQL_CALC_FOUND_ROWS On Table 1 --------------- Request 2: --------------- Execute: SQL_CALC_FOUND_ROWS On Table 2 --------------- Request 1: --------------- Execute: Select FOUND_ROWS( ) At this point, you see the race condition that occurred. While Request 1 was being executed, Request 2 came in. At this point Request 1 will return the number of Table Records in Table 2 and not Table 1 as expected! Again, is it correct? If it is, so we can not rely on FOUND_ROWS() function then?
View Replies !
Creating Databse To Insert Multiple Choice Questions
wanted to insert questions, options and correct answer in the database(Multiple choice questions). I have around 8000 questions to be inserted. I tried with copying entire content from word into notepad and provided delimiters for questions and answers but the entire question appears in a single line(it is big problem when question size is big)in the data base which i dont want to be /
View Replies !
Using Dates In PHP + MySQL
I have never used dates before but am currently trying to specify a date and have it insert into a database and ofcourse select that date for displaying later. I try to insert a date using a form (dates are specified from three drop down menus for day, date and month) but it keeps appearing in the database as the default '0000-00-00'. When I select it later I need it to simply display 9 Jan or 10 Apr, etc.
View Replies !
Querying Dates In Mysql
If I want to extract data with todays date then it's 'where blab blah = current_date()' For yesterday it's 'where blah blah = current_date()-1' But can anyone tell me how to extract all data from the start of the current week? Is there any way in Mysql to work out the start of the current week? The current month? Year?
View Replies !
Importing Dates Into MYSQL
I have a bunch of data to import into MySQl. One column is birthdate, stored (in Excel) as 10/11/1981 (example). When I import it into MySQl, it shows up as 0000-00-00 (hundreds of rows of this!) Even in OpenOffice, which lets me format the date as 1981-10-11, it still doesn't import to MySQL (still shows up as all zeros). Is it like others, do I need to "encapsulate" the date (like around # signs)? IF I set the MySQL field date to text, they import wonderfully, but the second I set that field back to date, they all go to zeros!
View Replies !
|