mysql

Is it a correct way to index TEXT column of MySQL database?

I have a map from strings to integers. To store this map in a MySQL database I created the following table: CREATE TABLE map( Argument TEXT NOT NULL, Image INTEGER NOT NULL ) I chose the TEXT type for the argument because its length is unpredictable, currently the longest record has 2290 chars and the average length is 88 chars. ...

Looking for a starting point for a tagging system.

Basically I want to setup a tagging system like stack overflow has for entries and trying to plan out how a relevance based search would work. I want to have an option to pull up similar tagged entries for a related entries section. Right now I am using two tables for tags, a table for each unique tag and a join table. I am trying to thi...

How can I redirect to a specified page after performing a MySQL insert or update?

After using form data to perform a MySQL update (via PHP), I'd like to direct the user to a page that displays that data as it will appear on the site. How can I automatically redirect the user to a page (preview.php, for example) AFTER running the MySQL update? I'd like to keep the solution to HTML or PHP if possible. ...

Why can't I do this INSERT in MYSQL? (Python MySQLdb)

This is a follow up to this question I asked earlier: http://stackoverflow.com/questions/2267034/why-cant-i-insert-into-mysql/2267076#2267076 That question solved it partly. Now I'm doing it in Python and it's not working :( cursor.execute("INSERT INTO life(user_id, utm) values(%s,PointFromWKB(point(%s,%s)))",the_user_id, utm_easting,...

PHP PDO bindValue in LIMIT

Here is a snapshot of my code: $fetchPictures = $PDO->prepare("SELECT * FROM pictures WHERE album = :albumId ORDER BY id ASC LIMIT :skip, :max"); $fetchPictures->bindValue(':albumId', $_GET['albumid'], PDO::PARAM_INT); if(isset($_GET['skip'])){ $fetchPictures->bindValue(':skip', trim($_GET['skip']), PDO::PARAM_INT); } else{ ...

How do I use the @ sign in Mysql?

A user on SO recently gave me this Query to put into MYSQL, but I don't know what to do with the @ sign. SELECT user_id, GLength(LineString(utm, @mypoint)) FROM users WHERE MBRWithin(utm, LineString(Point(X(@mypoint) - 20, Y(@mypoint - 20)), Point(X(@mypoint) + 20, Y(@mypoint + 20)) AND GLength(LineString(utm, @mypoint)) <...

Need help on a JOIN query that almost works

I have four tables. posts | id | title | +---------+-----------+ | 1 | hello | | 2 | goodbye | +---------+-----------+ posts_tags | tag_id | post_id | +---------+-----------+ | 1 | 1 | | 2 | 1 | | 2 | 2 | +---------+-----------+ comments | id | post_id | c...

Find the distance between two points in MYSQL. (using the Point Datatype)

Suppose I have a 2 column table like this: | user_id | int(11) | NO | UNI | NULL | | | utm | point | NO | MUL | NULL | | As you can see, it's very simple. utm is a Point data-type. I insert it like this: INSERT INTO mytable(user_id, utm) VALUES(1, PointFromWKB(point(50, 50))); ...

mysql is handling one sql query at the time?

if you got 100 000 users, is mysql executing one sql query at the time? cause in my php code i check if a certain row exists. if it doesn't it creates one. if it does, it just update the row counter. it crossed my mind that perhaps 100 users are checking if the row exists at the same time, and when it doesn't they all create one row ea...

Pagination script error--Why jumping back to first page?

PHP learner. The pagination script below seems to generally work, but the problem is that on each page of 20 records, when I select some rows (via checkboxes) and click the SUBMIT button, the display of 20 records jumps back to page 1. The rows are selected without a problem, but I can't grasp why it returns to page 1. Is the problem ...

Would like help thinking algorithmically about server-side video encoding.

I've been learning PHP and MySQL and have been thinking about exercises to help me learn the language better. I've used ffmpeg for a few years now to process video files and thought I could probably work out a way to manage this from the web. I've read up on using ffmpeg from php but I'm wondering how to manage the files on the backend. ...

help with sql query with parentheses

i have following code: SELECT * FROM table WHERE thread = $thread AND (user != $user1 OR user != $user2) i want the code to pick all rows that contains $thread BUT the user isn't $user1 or $user2. is my code correct? or should it be like: SELECT * FROM table WHERE thread = $thread (AND user != $user1 OR user != $user2) thanks in a...

help with a sql query

i need help with one more sql query. if i've got 2 columns in a table: tag1 tag2 and want to select rows that got either $tag1 OR $tag2 but never $tag1 AND $tag2, how could i write the sql query? i've tried with: SELECT id FROM tagPairs WHERE (tag1 IN ($tag1, $tag2)) OR (tag2 IN ($tag1, $tag2)) AND ((tag1 != $ta...

How to manage one to one relationship in mySql?

Hi all I've two tables one about Customers and the second one is about their Accounts as 'Customer_Account_Information'. we know that one customer can have only one account, so I'm trying to enforce one to one relationship, but i don't know the procedure/syntax in mySql or mySqlyog. is there any one who can help me? ...

Search in multiple tables

Let's say I have tree tables: [ news ] id title text date [ posts ] id title text date [ gallery ] id title text date How can I perform a FULLTEXT search in these tree tables with one query? I just want to run the search on the title and text fields and get the id, title, date and the...

Ignore duplicates when using INSERT in a Database with Symfony and Doctrine

I have a table CREATE TABLE `sob_tags_articles` ( `tag_id` int(11) NOT NULL, `article_id` int(11) NOT NULL, `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=112 And triing to save an object with Doctrine: $sbTagsArticles = new SobTagsArticles(); $sbTagsArticles->article_id = $pubId; $sb...

get id of last inserted record without using mysql_insert_id()

$sql = 'INSERT INTO customer (first_name, last_name, email, password, date_created, dob, gender, customer_type) VALUES(:first_name, :last_name, :email, :password, :date_created, :dob, :gender, :customer_type)' . ' SELECT LAST_INSERT_ID()' ; Can anyone tell me if the syntax is right? I am having problems usin...

search big database

I have a database which holds URL's in a table (along with other many details about the URL). I have another table which stores strings that I'm going to use to perform searches on each and every link. My database will be big, I'm expecting at least 5 million entries in the links table. The application which communicates with the user ...

mysql order by performance

Can I prevent using filesort in mysql when field on which condition in one table and field on which order in another. Can use index in this situation? Both tables are large - more than 1 million records ...

Database schema - organise by object or data?

I'm refactoring a horribly interwoven db schema, it's not that it's overly normalised; just grown ugly over time and not terribly well laid out. There are several tables (forum boards, forum posts, idea posts, blog entries) that share virtually identical data structures and composition, but are seperated simply because they represent di...