mysql

Using shell script to insert data into remote MYSQL database

I've been trying to get a shell(bash) script to insert a row into a REMOTE database, but i've been having some trouble :( The script is meant to upload a file to a server, get a URL,HASH, and a filesize, connect to a remote mysql database, and insert the data into an existing table. I've gotten it working until the remote MYSQL database...

Mysql create trigger 1064 error

The sql i wrote **delimiter | CREATE DEFINER=CURRENT_USER TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW BEGIN UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id END | delimiter ;** The error given [SQL] **CREATE DEFINER=CURRENT_USER TRIGG...

How Convert byte[] to varchar ?

SELECT Trainer.id AS idTrainer, surname, lastname, name, if(month = '', 'NO',month) as monthT, quarter, halfyear, year, id_Person, photo FROM Trainer, Person WHERE Trainer.id_Person = Person.id if(month = '', 'NO',month) as monthT in phpmyadmin return good or 'no' or month In a C# returns byte[], but I need return NO if month is emp...

What is better in python, a Dictionary or Mysql ?

What would be faster ? Query mysql to see if the piece of information i need is there, OR load a python dictionary with all the information then just check if the id is there If python is faster, then whats the best what to check if the id exists? Im using python 2.4.3 Im searching for data which is tagged to a square on a board, im s...

How to find and store the number of times a user was part of a search criteria

LinkedIn provides a mechanism to say that the user was part of a search criteria "n" number of times in the last "x" days. How do you go about capturing and storing the information. Are you supposed to iterate the search results and put an appropriate counter whenever they get searched or is there a non-intrusive mechanism by which this ...

Good tutorial on how to build a wiki with PHP & Mysql?

I'm searching for a good tutorial on how to build a wiki with PHP & MySQL. I need something that will show me how to structure the mysql database and which algorithms to implement for the text diff etc. The only one that I've found so far is this: http://www.ibm.com/developerworks/opensource/tutorials/os-php-wiki1/ But it is based on ca...

Need help in forumlating the query output in a certain fashion

We have a table which contains TV channel listings. create table listing (id, channel_name, event_name, event_time) a) listing (1, "ABC Channel", "All My Children", 6.00 AM) b) listing (2, "ABC Channel", "News", 7 AM) c) listing (3, "ABC Channel", "One life to live", 7.15 AM) d) listing (4, "ABC Channel", "General Hospital", 8.00 AM) e...

PHP escaping encoded quotes

I have following piece of code which posts some data into database: $post = trim( $post ); $post = htmlentities( $post, ENT_QUOTES, null, false ); $statement = "INSERT INTO table (row) VALUES (:message)"; $prepared_posts = $pdo->prepare( $statement ); $prepared_posts->execute( array( ':message' => $post ) ); I have MySQL version 5.1....

2 identfical sql queries w' diff params - only one requires temp table

The only difference in these sql queries is the record_id param (it's how I page through entire result set). The tables are myisam. The first query performs well and the second is terribly slow. Any idea why this would be? This query works fine explain select r.record_id, r.oai_datestamp, r.format_id, r.status, x.xml, max(u.date_u...

Query for results ordered by column of association table, most recent association only

given the following schema class User has_many :page_views #[id] end class Page has_many :page_views #[id] end class PageView belongs_to :user belongs_to :page #[id, created_at, updated_at] end How can i query for a given page, all users most recent page views in order by created_at date. One row per user, showing only...

"Illegal mix of collations" error from MySql while running rails test suite

I've recently dusted off an old Ruby on Rails project of mine. In the past, I've never had any problems getting all the tests to pass, but now there is one test that gives me the following error: ActiveRecord::StatementInvalid: Mysql::Error: #HY000Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)...

Strange behaviour of JOIN

Hi all, I have a strange problem with my query trying to join 3 tables. The tables descibed: 2 similar tables like this (entr_es): Field Type Null Key Default Extra espid int(11) NO PRI NULL auto_increment haslo text NO MUL NULL kat int(11) NO NULL The second table looks the same, except the first colum...

How can I delete duplicate mysql column entries?

I have a mysql table named "dev" with a column of "email"s. I want to select out all the unique e-mail addresses and delete the duplicates. My structure is as follows: id || email 1 [email protected] 2 [email protected] 3 [email protected] What I want is... id || email 1 user1@exa...

mysql complex update and replace

Hey everyone, I've got an interesting query that I wonder if anyone can help with? Basically, I have three tables, Title, Attribute and Attribute_Value Title contains a list of templates like 'Created on {Date} by {User} in {Category}' then in the Attribute table, I have rows that contain a definition of the parameters wrapped in cur...

MySQL - Searching with UNION ALL and GROUP BY

SELECT p.id, p.title, p.uri, 'post' AS search_type FROM `posts` AS p WHERE title LIKE "%logo%" UNION ALL SELECT p.id, p.title, p.uri, 'tag' AS search_type FROM posts AS p INNER JOIN post_tags AS pt ON pt.post_id = p.id INNER JOIN tags AS t ON pt.tag_id = t.id WHERE t.title LIKE "%logo%" UNION ALL SELECT p.id, p.title, p.uri, 'c...

php, mysql, how can I get the field name inside my dynamic sql html table loop ?

I'd like to do something different depending on field name in my loop. My code dynamically produces a html table based on the fields used in the sql query. I'd like to produce a link to a certain page if the field in the loop is the primary key... Any ideas ? I've marked where I need to get the field name with HERE. if (mysql_num_...

MySQL SELECT from a group of tables retrieved from INFORMATION_SCHEMA

Hey all. I've got the following set of tables which is variable and adds up every day: data-2010-10-10 data-2010-10-11 data-2010-10-12 data-2010-10-13 And so on. All the tables have the same structure and what I'd like to do is select stuff from all tables at once. I'm unable to use a MERGE table since I'm running InnoDB. Anyways, I'm...

Find condition in cakePHP with Containable behavior

Hi, I have 2 models, User and Evolution. User has many Evolution, Evolution belongs to User. I have 10 000 users and I want to do a condition that give me 500 users that DON'T have today's date in the Evolution table. Originally, I was taking every one in the USER table and then I was looking if they had their row in Evolution like: ...

SQL parser for Wordpress NoSQL Fork

Call me crazy but I'm planning to Fork wordpress. I'm planning to swap out MySQL for Apache Cassandra. Call it ambitious but I'm planning to devote a chunk of time over the next few months. In any case my question is: I'm trying to aim to keep plugins working... In essence any plugin that doesn't require their own table should be able t...

How large can the array passed to SQL where column_value IN (Array) be?

I am writing some code that will lookup for unique id's in a table with over 60,000 rows for the ones that are in an array using mysql_query("SELECT * FROM users WHERE unique_indexed_user_id IN('".join("', '", $array)."')") ; the amount of this array is not limited to the end user so they might end up selecting a large array. thus I...