mysql

Selecting uniques in MySQL across two tables?

I have two tables, genre and genre_apps Genre has the following fields: export_date genre_id parent_id name genre_apps has the following fields: export_date genre_id application_id is_primary What I would like to do is show all the unique names within genre_apps. I have tried this SELECT genre.name from grenre inner_join genre_App...

MySql in array order?

I have a statement like the below. The order returned is 1,4,5. My code expects 4,5,1 because of output precedence rules. How do i make mysql return the order i specified? select * from Post where flag='0' and id in(4,5,1) ...

How to only SELECT part of column value by REGEXP with MySQL ?

Hi, I have a column with values like "A001", "B002" AND "003", "004". I would like have this result : SELECT column from myTable +--------+ | column | +--------+ | 001 | | 002 | | 003 | | 004 | +--------+ Is this possible ? ...

MySql function not using indexes

Hi. I have simple function consist of one sql query CREATE FUNCTION `GetProductIDFunc`( in_title char (14) ) RETURNS bigint(20) BEGIN declare out_id bigint; select id into out_id from products where title = in_title limit 1; RETURN out_id; END Execution time of this function takes 5 seconds select Benchmark(500...

Wordpress COMMENTS IN URDU (other language)

I am working on a wordpress project. The my database is in utf general. It seems everything is fine in database side, the rest of the website is working wel except the comments. When i display comments wordpress just display symbols rather than words can anyone help me? ...

ActiveRecord / MySQL Select Condition Comparing String Components

I have a string that is defined as one or more dot-separated integers like 12345, 543.21, 109.87.654, etc. I'm storing values in a MySQL database and then need to find the rows that compare with a provided value. What I want is to select rows by comparing each component of the string against the corresponding component of the input strin...

free calendar with timestamp

I am working on form and I am looking for a free calendar/date/timestamp app that i can include in my form. basically, in the input text, i want users to click on the calendar icon and pick a date and a time stamp. that value should populate in the input text. my next question is, in my mysql db, i am calling this field as "datetime", s...

SQL query problem

I have one column of varchar type which store numbers like 10, 11, 16.5, 24, 43, 12, 100 etc I want to order these field. but it sort like these 10 11 12 16.5 100 24 43 expected 10 11 12 16.5 24 43 100 please help ...

Simple SQL case issue - returning 0 when NULL

Apparently NUMBER + NULL returns NULL in SQL. So I need it to add 0 instead of NULL but this isn't working, I'm getting a syntax error. I'm looking at the docs and this is what it says to do so I'm not sure... SELECT sku, (qty + (SELECT (CASE qty WHEN IS NULL THEN 0 ELSE qty END) FROM other WHERE sku = Sheet1.sku LIMIT 1)) as qty FROM...

mysql phpmyadmin user password for database

i am using phpmyadmin; i created a database; now i want to locate the username and password for this new database i created. note, i am not sys admin, i am only the developer, but i do have access to create db on mysql in phpmyadmin. does my sys admin needs to tell me the username and password to access this db, or i can telnet and get i...

SELECT inside a COUNT

I would like to embed a SELECT inside a COUNT, but I can't find any examples. #pseudosql SELECT a AS current_a, COUNT(*) AS b, COUNT( SELECT FROM t WHERE a = current_a AND c = 'const' ) as d, from t group by a order by b desc ...

Problem with Rails using Load balancer and Multi-Master-Manager (MMM) for Mysql

I have configured Rails to run with Multi Master Manager for Mysql (http://mysql-mmm.org) We also have a load balancer to distribute the DB request, so here is the setup: rails | load balancer (LB) / | \ db1 | db2 \ | / MMM If one of the db is down, everything is fine, MMM...

MySQL Copy table structure vs. Creating with statement

Ok so I was wondering if there is a big difference performance and efficiency wise between creating a table in MySQL with a full Create table statement vs. Copying the structure of another table that has the same layout. I ask because there are going to be multiple, and I mean a lot, of tables being created so I wanted to see if copying ...

Joining and sorting results of two tables in MySQL

Hi, I have two tables in MySQL, one containing a field City and one containing a field HomeCounty. I need to get X number of records sorted alphabetically so that both City and HomeCounty are taken into the set. I can't join, because these two tables have no relation... and because I need these two columns to be "one", not two. So, I ...

SQLAlchemy and max_allowed_packet problem

Due to the nature of my application, I need to support fast inserts of large volumes of data into the database. Using executemany() increases performance, but there's a caveat. For example, MySQL has a configuration parameter called max_allowed_packet, and if the total size of my insert queries exceeds its value, MySQL throws an error. ...

Perl Connection Pooling

Right now we have a large perl application that is using raw DBI to connect to MySQL and execute SQL statements. It creates a connection each time and terminates. Were starting to approach mysql's connection limit (200 at once) It looks like DBIx::Connection supports application layer connection pooling. Has anybody had any experience...

Mysql join query for multiple "tags" (many-to-many relationship) that matches ALL tags?

I am trying to query for Objects that match ALL of a given set of Tags. Basically I want users to be able to add on more and more Tags to filter or "narrow down" their search results, kind of like newegg.com does. My table structure is a table of Objects, a table of Tags, and a MANY:MANY relation table ObjectsTags. So I have a JOIN qu...

JDBC: Converting Clobs to Strings doesn't show \n line returns

Hi, I am connecting to a 4D (fourth dimension brand) database with its crappy jdbc driver. I have a CLOB on the database and when I fetch it either through getString or getClob, I don't get line returns, everything seems to come in one line. But, if I do do a select on NetBeans database explorer and I copy and paste the value on the ...

Checking date from database

Hey, I am looking to produce a function where I check the date is in the last fortnight. This is something I have never done before. I have produced a mysql_query $q = "SELECT date_subbmited FROM ".TBL_CONF_RESULTS." WHERE home_user = '$u' OR away_user = '$u'"; That would select the date and in PHP i could check whether it was in th...

Unix timestamp to seconds, minutes, hours

I need to somehow take a unix timestamp and output it like below Can this be done with MySQL? Or php Mike 7s ago Jim 44s ago John 59s ago Amanda 1m ago Ryan 1m ago Sarah 1...