mysql

mysql join on two fields

I have two tables with date and id fields, and i need to join on both fields. I tried [code] JOIN t2 ON CONCAT(t1.id, t1.date)=CONCAT(t2.id, t2.date) [/code] that works, but it is very slow. is there a better way to do this? ...

Using jquery .ajax to retrieve records from mySQL DB

I am a mySQL noob, and have a slightly stupid question... I am using jquery to send form to a php script which then stores the data in a mySQL database. On another page in my app, I need to get all the values from one column of said mySQL DB, using jquery again (I assume I will also have to write another php script) so I can use the re...

How do I Interupt a long query in the mysql command line tool without quitting mysql?

While debugging SQL statements, if I accidentally execute a query in using the mysql command line that outputs at lot of results (even if the query itself executes in reasonable time), the only way I know of to stop the endless stream of output is CTRL-C. Unfortunately this puts me back in the shell, forcing me to login and select the ...

Most elegant solution for humungous problem

I'm working on a site where a user could select certain dates that apply to them, e.g Date 1,Date 2, Date 3, etc. Each date will have certain questions belonging to it, so if the customer checked off 'Date 1' to indicate that this date applies to him, he'll then see a bunch of textboxes asking him about Date 1 and how it applies to them...

In SQL how can I have two fields that can't both be identical, only one is a primary key

I'm useing MySQL and I have three tables, a table of tasks, a table of products and a table that describes the relation between the two: Each product is composed of several tasks, and each task may be found in multiple products. The table that describes the relationship between the two has two primary keys, ProductID and TaskID that are...

I need to change the date format using php.

Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line echo "<td><strong> ("d/m/y",". $row['date'] .")</strong></t...

MySQL vs File Databases

So I'm going to be working on a home made blog system in PHP and I was wondering which way of storing data is the fastest. I could go in the MySQL direction, or I could go with my own little way of doing it which is storing all of the information (encoded in JSON) in files. Which way would be the fastest, MySQL or JSON files? ...

Listing of All Mysql Data Types and Syntax For All Settings

I'm looking for a listing of all MySQL data types and the available settings for each option for each data type. After a bit of googling I couldn't find anything quite like that. ...

Removing an Appended " In front of Every Column

I found a CSV database of Cities/ZIP/GPS, and when I imported it, it added a " infront of the columns. I don't want to go in for 33,000 entries and do this manually, is there a query I can run that will remove the quotes? ...

understanding results of global.time_zone

Hi I'm looking into ways of changing the time zone of my databases as my userbase is UK based, but my domain is US based. I've researched a number of options including php, PEAR time class, and MySQL functions. To me the simplest (largly because it starts and ends with MySQL) involves changing MySQL's time_zone parameter. In preparat...

Place multiple similar fields in multi-dimensional array - php mysql

Hi, I want to execute an SQL query like: select 'tb1'.'f1','tb1'.'f2','tb2'.'f1' from 'tb1','tb2'; Now the problem is that i want to put it into an array in PHP like: $result['tb1']['f1'], $result['tb1']['f2'], $result['tb2']['f1']... Any idea how to achieve the above? Afaik there is no function which does the above. I was wond...

MySQL NOT LIKE query not working

I have 2 tables: posts tags Tags table is structured like this: post_id tag So for every tag that's given for a post, I create a record in the tags table. If a post has 10 tags, there will be 10 records in tags table with that post_id. I'm now trying to build a search page where users can do a search for posts where tags do not ...

How to conduct an Accent Sensitive search in MySql

I have a MySQL table with utf8 general ci collation. In the table, I can see two entries: abad abád I am using a query that looks like this: SELECT * FROM `words` WHERE `word` = 'abád' The query result gives both words: abad abád Is there a way to indicate that I only want MySQL to find the accented word? I want the query to only...

Can stored procedure in MySql 5.0.x be encrypted?

In Microsoft Sql it is possible to encrypted stored procedures with CREATE PROCEDURE dbo.foo WITH ENCRYPTION AS BEGIN SELECT 'foo' END This stops people looking at stored procedures code. How can I do this in MySql 5.0.x ? ...

Rails 2.2.2 Performance Problem/Bug

I recently upgraded one of my applications to Rails 2.2.2. Having done that, I've encountered a strange performance bug that has caused renders that used to complete in a fraction of a second to take up to 10 seconds. I've profiled the issue, and here are the results I've come up with. It looks like the issue is in the real_connect me...

Using 'distinct' in a MySQL query

I have the following query. "SELECT p.author_name, p.author_id, DISTINCT p.topic_id, t.title FROM `ibf_posts` p, `ibf_topics` t WHERE p.topic_id = t.tid ORDER BY pid DESC LIMIT 8" When I run it, I get the following mysql Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL s...

Google-like Search Engine in PHP/mySQL

We have OCRed thousands of pages of newspaper articles. The newspaper, issue, date, page number and OCRed text of each page has been put into a mySQL database. We now want to build a Google-like search engine in PHP to find the pages given a query. It's got to be fast, and take no more than a second for any search. How should we do i...

How to implement a "who's online" feature in PHP?

How would one go about implementing a "who's online" feature using PHP? Of course, it would involve using timestamps, and, after looking at phpBB's session table, might involve storing latest visits in a database. Is this an efficient method, or are there better ways of implementing this idea? Edit: I made this community wiki accidenta...

Is there a tool to help with conflict resolution during MySQL replication?

Hi, Can I find out if there're good tools available for helping with conflict resolution during the replication process? Specifically MySQL. ...

Too many open files error on Ubuntu 8.04

mysqldump: Couldn't execute 'show fields from `tablename`': Out of resources when opening file './databasename/tablename#P#p125.MYD' (Errcode: 24) (23) on checking the error 24 on the shell it says >>perror 24 OS error code 24: Too many open files how do I solve this? ...