mysql

mysql index adding

Hi, We have 50 tables in our mysql database. Queries are taking time as many of the tables have more than 15K records. I know adding indexes increases the query performance, my query is, on adding indexes on existing tables will have any harm to existing users? Please share your thoughts. Thanks. ...

MySQL: UPDATEing a row with no guaranteed unique field

I am working with an old MySQL table, which serves as a log of sorts. It looks like CREATE TABLE `queries` ( `Email` char(32) NOT NULL DEFAULT '', `Query` blob, `NumRecords` int(5) unsigned DEFAULT NULL, `Date` date DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Now, I need to be able to UPDATE the records in this table ...

mysql converting multiple rows into columns in a single row

Hi, i have a details table with columns: user_id int code int value int And i want to build a summary table that looks like: user_id int valueA int valueB int In the details table, valueA would correspond to say, code 5, and valueB would correspond to say, code 6, so i'm looking for something like: insert into summary (user_id,v...

Combine count rows in MySQL

I've got a table in MySQL that looks roughly like: value | count ------------- Fred | 7 FRED | 1 Roger | 3 roger | 1 That is, it was created with string ops outside of MySQL, so the values are case- and trailing-whitespace-sensitive. I want it to look like: value | count ------------- Fred | 8 Roger | 4 That is, managed by MySQ...

Border-Line Cases: MySQL Point-in_Polygon Function Results in Duplicates When the Point is on the Border

Hi, I'm using MySQL to pull lat longs from a database and check whether or not they are in a particular neighborhood. Everything works great, except if the point is on the border between two neighborhoods. Then, the point is included in both neighborhoods. It gets duplicated. What's the best way to handle points that are on borders? ...

Display a random set of 10 questions and answers with MySQL and PHP

I'm making a survey with PHP and MySQL. I'm having trouble figuring out what method to use to display a random set of 10 questions, and their answers. Each question can have between 2 and 5 answers. Here is how the database is set up: questions: ID | quID | question answers: ID | an_quID | anID | answer quID and an_quID link the tab...

when TEXT isn't enough for a record entry?

My site allows users to submit After Action Reports and yesterday someone set the new record with a ~48,000 character beast of a report. While that's still only 74% of the TEXT maximum character count, it made me wonder what should be done when someone wants to submit something that exceeds the 65k limit...? It's bound to happen eventual...

Inserting a Japanese XML feed in to a MYSQL table via PHP

Hi I've been looking for a solution to this issue and have tried most answers found. But with no luck was I able to insert the Japanese xml feed into the tables which have been created. I tried setting all setting where UTF8 should be used as most answers have suggested - But no luck!! Can someone guide me through. Thanks Sam ...

dynamic MySQL query/view for crosstab

I currently have a hard coded view with the following sql: select username ,(case user_role.role_id when 1 then true else false end) as ROLE_SUPER ,(case user_role.role_id when 2 then true else false end) as ROLE_ADMIN ,(case user_role.role_id when 3 then true else false end) as ROLE_VIEW ,(case user_role.role_id whe...

How to insert a string that contains quote marks into a database?

When I try to instert a string that contains a quote mark, the INSERT query fails. How can I insert strings with single or double quotes? for example: $message = "Bob said 'don't forget to call me'"; mysql_query("INSERT INTO someTable (messages) VALUES ('$message')"); I figure the input needs to be filtered but which function should...

display js inside php while loop

I found the count down script in http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm It works fine if i just define the date but when I try to pass the date from this php/mysql query into the js file, it works only for the first record and not after that. <script type="text/javascript" src ="time.js"></script>//this is the script ...

MySQL multiple table query with average for each row

This is my setup: Table "files": id (PK), filename, user_id, date, filesize Table "scores": id(PK), file_id, user_id, score Table "files" contains a list of files with details; table "scores" keeps track of 1-5 points scored per file. I need to get entries from the "files" table and in each row I need all the info for the file, as we...

mysql list comparison problem with query logic

Hello, I am comparing two lists of email addresses in mysql - listA and listB (both of which are views). Originally, I wanted to find all of the email addresses in listA that are not in listB. I successfully accomplished that with: $comparison_query = mysql_query("SELECT DISTINCT email_addresses FROM listA WHERE email_addresses NOT IN ...

combobox treeview in php & mysql

Does anyone know how to display MySQL db hierarchical data (Nested Set Model (http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-MySQL.html)) in a combo box as shown here under the "Category:" comboxbox field:http://dir.globetourism.biz/submit.php Thanks ...

How to set Timeout for a mysql query in Java ?

I want to set some timeout for a mysql query to execute in java. ...

Monitoring MySql for query frequency

Around the time of a release I saw in Munin that the number of queries increased dramatically, on a regular frequency. These aren't slow queries. Rather than doing the brute force method of going over my code to see what is causing the excessive number of queries, I'd like to know if there's an open source solution that can monitor a run...

How do I do a levenstein similarity algorithm in MYSQL?

Sure, I can write a function for it in Python or something...but how can I do it in MYSQL? WHERE title = "heart of darkness" more or less 3 characters... ...

How to select distinct rows from a table and join the selected row to another table in mysql

Hi, I have a query like below to select 'sid' with highest count and its 'lid'. Now I'd like to select details of 'lid' from another table and keep the 'tot' in the result set. Is that possible? select count(distinct sid) as tot, lid from wt_stats_linkclicks where statsid IN (1) GROUP BY lid order by tot DESC limit 1 Thanks! ...

How do I create a period date range from a mysql table grouping every common sequence of value in a column

My goal is to return a start and end date having same value in a column. Here is my table. The (*) have been marked to give you the idea of how I want to get "EndDate" for every similar sequence value of A & B columns ID | DayDate | A | B ----------------------------------------------- 1 | 2010/07/1 | 200 | 300 2 | 2010/07/2 | 2...

How to display the random images without repetition from database(MySql) using php

Hi Everyone, I have a program in php that should display the random images without repetition,I was able to store the images in the database, but I don't have any idea to do this can anyone help me with this. Thank you, ...