mysql

MySQL: Pivot + Counting

I need help with a SQL that will convert this table: =================== | Id | FK | Status| =================== | 1 | A | 100 | | 2 | A | 101 | | 3 | B | 100 | | 4 | B | 101 | | 5 | C | 100 | | 6 | C | 101 | | 7 | A | 102 | | 8 | A | 102 | | 9 | B | 102 | | 10 | B | 102 | =================== to ...

What is causing the apparent change in behavior of affected_rows() in mysql & PHP

Somewhere around 5.0.x mysql changed the behavior of affected_rows() - It used to not return information only for UPDATE, DELETE - and in a latter version was updated to also return the # of rows selected by a SELECT. Am I right or wrong and in what version? Or what mysql driver is needed? (Ex. does it only happen with mysqldnd or with ...

How can I optimize a query that does an ORDER BY on a derived column in MySQL?

I am having trouble optimizing a relatively simple query involving a GROUP BY, ORDER BY, and LIMIT. The table has just over 300,000 records. Here's the schema (I added some extra indexes to experiment with): CREATE TABLE `scrape_search_results` ( `id` int(11) NOT NULL auto_increment, `creative_id` int(11) NOT NULL, `url_id` int(...

selecting previous and next rows in mysql - how?

I can't figure out how to select a previous/next row IF the current row does not have any numeric identifiers. With numeric value I always use 2 queries: SELECT min(customer_id) FROM customers WHERE `customer_id` < 10 GROUP BY customer_status ORDER BY customer_name ASC LIMIT 1; SELECT max(customer_id) FROM custo...

php remote login to mysql db

hello, trying to allow site1 to access a db on site2. site2 has site1 on the allow list for remote access. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $host="host.com"; // Host name $username="user"; // Mysql username $password="pw"; // Mysql password $db_name="mydb"; // Database name $tbl_name="userCred"; // Tab...

Is there no mysql connector for python 2.7 on windows

While I see a bunch of links/binaries for mysql connector for python 2.6, I don't see one for 2.7 To use django, should I just revert to 2.6 or is there a way out ? I'm using windows 7 64bit django - 1.1 Mysql 5.1.50 Any pointers would be great. ...

PHP - Add String to Array

Hello everyone, I am wondering how I can add a string variable to the current array. For example, I have an array called $finalarray. Then I have a loop that adds a value on every run. Basically: $finalarray = $results_array + string; A very basic structure. I am using this for MySQL so that I can retrieve the final array of the colu...

PHP remote login to mysql db: "cannot select db"

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); $host="host.org"; // Host name $username="myServer_guest"; // Mysql username $password="password"; // Mysql password $db_name="myServer_JMblog"; // Database name $tbl_name="blog"; // Table name // Connect to server and select databse. $link=mysql_connect("$host", "$user...

How to get multiple columns in one variable in mysql query

I have the table Articles -------- id,name,type_id Type--------------id,name article_type ----------article_id , type_id I using this query select A.name from types A inner join article_type B on ( B.type_id = A.id and article_id = 10) Now this query is working but it gives me separate rows but i want all types in one variables so...

Error on updating record with Subsonic (MySql)

Hi, I am using the following code to update a record in my table: var usr = test.Data.user.SingleOrDefault(y => y.id == 1); usr.name = "test"; usr.Save(); retrieving the row works perfectly but when I Save() I get a NullReferenceException breaking in the file database.cs line 412, which...

What size INT should I use for my autoincrement ids MySQL

Currently we're using INT(21)* for all autoincrement id columns in out 30+ table database. We are a blogging site, and have tables storing members, comments, blog posts and the like. I'm quite sure we will never reach the limit of our INT(21) id columns, and would like to know: If using INT(21) when I am sure we'll never need it is ...

SQL Join with Null Values

My Query does not work when I have not set the ProcessorID in myComputer table How can I make a query that will show me the ProcessorName when I have a value assigned in ProcessorID or NULL when I don't? CREATE TABLE myProcessor ( ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Name VARCHAR(255) NOT NULL ) ENGINE=InnoDB; INSERT IN...

double checking my mysql field lengths

I am creating my first serious project in PHP and I want to make sure I have my database setup correctly. It is utf8_general_ci and for example the max I want usernames to be is 20 characters, so the username field in the database would be a varchar(20)? Sorry if this is stupid, it is just I read something somewhere that is making me que...

Question on multi-row insertion with subqueries

Say I have the following 2 tables, CREATE TABLE t1( name VARCHAR(25) NOT NULL, time INT, a INT ); CREATE TABLE t2( name VARCHAR(25) NOT NULL, time INT, b INT ); and Im looking to pull all the values (a) out of t1 with a given time, all the values with the previous time (say just time-1 for convenience) then for each name ...

Access Mysql server using socks proxy from a php script

Possible Duplicate: mysql proxy socks I need to access a mysql server using socks proxy from a php script. Please could anyone help me to do this. ...

what is write way to multiple sorting in mysql

how i can use multiple sorting in mysql ORDER BY PARAM1 , PARAM2 or ORDER BY PARAM1 AND PARAM2 AND PARAM3 DESC what is write way to sorting in mysql ...

php json_encode mysql result

I have a simple mysql_query and I would like to encode the results(title= > $title, price => $price etc) in json . $sql = mysql_query("SELECT * FROM item_details WHERE posting_id='$item_number'"); while($row = mysql_fetch_array($sql)) { $title = base64_decode($row['title']); $price = $row['price']; $seller_user = $row['user...

How to decrypt the key

Using C#, JavaScript & mysql In the database i have the column like sign, sign ONr3XHNaUuROnolZpGSsdI+/b3mfOuXnBW7bW7M7cEBqE1RljubGNyc3f1ilFB1qJC9RkeZgaYcWFF1Z7DbgdHES78AAFYIcGMg5kzQdjR0wr1EQgmW+Z4TfmdmMlwNzbsdCPn6s0Bmlxt5HJ893KLrBGYhIRQre2JVje6u85Qk= cqz+/tEn2q2Hc7Cwa7bXGYY6K77v37bZOW2HMfSCdmwh/qoFyFCvWo8wH9JpUnHV5V5359ak1fy3/jkO/bIED...

Mysql : Join/Relating two tables

I have two table 1. Airline -id(primary), name 2. Form - id(primary), operator, other unwanted fields I want to relate Airline.name to Form.operator. Is it possible since Form.operator is not primary key, if yes give me the query. Can some one also guide me as how will the cakephp model relation be in this case ...

Storing Data in MySQL as JSON

I thought this was a n00b thing to do, and so i've never done it than i saw that FriendFeed did this and actually made their DB scale better and decreased latency. I'm curious if I should do this, and if so, what's the right way to do it? Basically, whats a good place to learn how to store everything in MySQL as a couchDB sort of DB. St...