mysql

Finding Cities within 'X' Kilometers (or Miles)

This may or may not be clear, leave me a comment if I am off base, or you need more information. Perhaps there is a solution out there already for what I want in PHP. I am looking for a function that will add or subtract a distance from a longitude OR latitude value. Reason: I have a database with all Latitudes and Longitudes in it ...

Singular or plural database table names ?

Exact Duplicate Table Naming Dilemma: Singular vs. Plural Names Is it better to use singular or plural database table names ? Is there an accepted standard ? I've heard arguments for and against it, what do you guys think ? ...

COUNT(*) and LEFT JOIN

This query: SELECT staff.staff_id, COUNT(references_table.staff_id) FROM staff LEFT JOIN references_table USING (staff_id) returns this: staff_id COUNT(references_table.staff_id) 1 2 How can I get it to return 0 as the count for staff_ids that don't have any references? ...

Insert similar data into two tables

Hello all.. I have the following code I use to insert form data into a single table in my db.` function insert_interests($uid, $interests) { /* first, we'll delete any entries this user already has in the table */ purge_lookup("jss_users_interests_table", $uid); /* now create the sql insert query */ global $db; $db->query(create_chec...

Mysql Dropping Connection

I am on Instant Ruby on Rails Mysql version 5.0.27, developing a system and all was going ok (sort of). Now the database keeps dropping. I found some comments that the userid needs to be root and password blank, I had changed the password, so I changed it back. Views run fine displaying and making changes than 500 Internal error, log say...

Best practice for comment voting database structure

I'm working on a PHP app that has several objects that can be commented on. Each comment can be voted on, with users being able to give it +1 or -1 (like Digg or Reddit). Right now I'm planning on having a 'votes' table that has carries user_id and their vote info, which seems to work fine. The thing is, each object has hundreds of co...

Database Search Term Highlighting and Result Truncating

I am currently performing a full text search on my "pages" in a database. While users get the results they want, I am unable to provide them with relevant information as to why in the world the results that came up, came up. Specifications on what I am looking for: I have HTML Data, meaning that if you search for a term such as "test"...

MySQL Proxy Alternatives for Database Sharding

Are there any alternatives for MySQL Proxy. I don't want to use it since it's still in alpha. I will have 10 MySQL servers with table_1 table_2 table_3 table_4 ... table_10 spread across the 10 servers. Each table is identical in their structure, their just shards with different data sets. Is there a alternative to MySQL Proxy, where...

How to create a page to edit a database

I'm trying to build a website that provides a login for users. Once these users login, they will be able to perform functions that will likely query a database. At some point I will need to add/modify/delete contents in the database and I'm wondering how I would be able create a page on the website that I'd only have access to. Ideally I...

MySQL Cross Server Select Query

Hi, Is it possible to write a cross server select query using MySQL Client. Basically the setup is like follows. Server IP       Database ---------       -------- 1.2.3.4       Test a.b.c.d       Test I want to write a query that will select rows from a table in the Test Database on 1.2.3.4 and inse...

Generic way in MySQL to get the top results

Say for instance I have a table which has names of people and their ages. I want a generic query in MySQL which will pull out the n oldest people. I could use something like this: SELECT * FROM people ORDER BY age DESC LIMIT 1; Say Frank and Emily are both 99 years old. The limit 1 will only return one of their names. In psuedo-sql I...

MySQL Performance without Authentication

Is there any way to grant permission to a MySQL Server based on the host and not the username/password. So whitelisted hosts can connect to the MySQL server without using a username or password. Would doing so improve performance at all? (the servers are on a LAN that's not connected to the internet at all, security is of no concern ...

MySQL Stored Procedure vs PHP script

I'm running a website for a jewellery wholesaler. The prices on all their products are calculated using the current bullion metal fixes that are updated every night. Currently, for the website, the calculations are worked out via a php include function, which works fine under current circumstances. There are around 10,000 products, bu...

PHP - Simple way to read single record from MySQL

What's the best way with PHP to read single record from Mysql please? SELECT id FROM games I was trying to find in old questions, but had no luck Thank you ...

Infrastructure required for a large Scale PHP Project

Hi My team is developing a large music portal in PHP. It is hoped that the portal will have 1 million+ users within a year of its launch. The portal will allow users to create playlists, stream and download music. Till now, we have developed applications that have been used by a maximum of about a 1000 simultaneous users. This portal ...

How to insert and update multiple rows to Sql database with same query?

I have counter for unique column in my table. Now I have list where I have column name (which is unique) and counter (which contains some integer value). I know that it is possible to insert multiple lines, I just could make query containing all those items on the list, but problem is that if there is already data in unique field. In th...

Is there a noticable difference between innodb and XtraDB?

Today on serverfault I read about XtraDB. I read that it was a fork of innoDB and was woundering how big are the differences? Would I notice the change or do you think its just wasted time if I would try it out? ...

MySQL - ignore insert error: duplicate entry

I am working in PHP. Please what's the proper way of inserting new records into the DB, which has unique field. I am inserting lot of records in a batch and I just want the new ones to be inserted and I don't want any error for the duplicate entry. Is there only way to first make a SELECT and to see if the entry is already there before...

Optimizing MySQL Aggregation Query

Hi All, I've got a very large table (~100Million Records) in MySQL that contains information about files. One of the pieces of information is the modified date of each file. I need to write a query that will count the number of files that fit into specified date ranges. To do that I made a small table that specifies these ranges (all i...

Faster way to delete matching rows?

I'm a relative novice when it comes to databases. We are using MySQL and I'm currently trying to speed up a SQL statement that seems to take a while to run. I looked around on SO for a similar question but didn't find one. The goal is to remove all the rows in table A that have a matching id in table B. I'm currently doing the follow...