How can I find the most frequent value in a given column in an SQL table? For example, for this table it should return two since it is the most frequent value: one two two three
Tag: mysql
MySQL 1062 – Duplicate entry ‘0’ for key ‘PRIMARY’
I have the following table in MySQL version 5.5.24 DROP TABLE IF EXISTS `momento_distribution`; CREATE TABLE IF NOT EXISTS `momento_distribution` ( `momento_id` INT(11) NOT NULL, `…
Can’t UNION ALL on a temporary table?
I’m trying to run the following simple test- creating a temp table, and then UNIONing two different selections: CREATE TEMPORARY TABLE tmp SELECT * FROM people; SELECT * FROM tmp UNION ALL SELECT * …
PhpMyAdmin does not show Query results operations at the bottom of Query Result
I can see Query results operations which gives me a way to export my query result for some queries but not for others where there is a query with bunch of joins. I feel its the type of Query. Is that the reason or is it the number of results? Snapshot of the actual query : Replaced the variables for
fetching a row in the middle of the table
Table reservation contains 500,000 records and bx_date varies from 2012-01-01 to 2013-01-01. 40,000 records in users table. bx_date is ‘date’ type. With the query above if I tried a date like 2012-08-22, It takes 8 secs. But if I tried 2013-01-01 It takes like 1 sec. What is the reason? Answer The most likely cause is improper indexing or index
getting count from the same column in a mysql table?
I wanted to a count of the same field for different values for example: user{user_id, gender} Gender can have obviously male or female 🙂 i want to get count for all the males and females i.e. but im confused because they come from the same gender coloumn thanks Answer Try this for row wise result: Output: Try this for row
Search a whole table in mySQL for a string
I’m trying to search a whole table in mySQL for a string. I want to search all fields and all entrees of a table, returning each full entry that contains the specified text. I can’t figure out how to search multiple fields easily; here are the details: The table is “clients”. It has about 30 fields and 800 entries, too
Differences between PostgreSQL and MySQL for PHP developers
For a project where most queries on the database will include requirements like “within an polygon” I have come to think about choosing PostgreSQL with PostGIS instead of MySQL, which I have previously mainly used. Mainly because PostgreSQL has more GIS functions. However, I am uncertain how to evaluate this, and also can’t really see the difference from a PHP
How to join the same table twice?
I am stuck on creating a SQL query. I have the following two tables: sender and receiver are foreign keys with table member and column memberid. I want to display list of messages with name and id of sender and receiver. How can I establish proper joins here? Answer You can try something like
Can I parameterize the table name in a prepared statement?
I’ve used the mysqli_stmt_bind_param function several times. However, if I separate variables that I’m trying to protect against SQL injection I run into errors. Here’s some code sample: Is it possible to somehow replace the .$new_table. concatenation with another question mark statement, make another bind parameter statement, or add onto the existing one to protect against SQL injection? Like this