mysql

Create Mysql Stored Procedure using in vb .NET

How do I create a stored procedure for mysql using VB .NET programmatically? EDIT: Apologize to be so brief. I have tried using ExecuteNonQuery provided by MySQL .NET Connector. It prompts me error. Maybe it's because I put "Delimiter $$"? I know I can create using script (batch file) if I want to send it to my client (as commented b...

How to store varbinary in MySQL?

Just a quick question.. Out of two options mentioned below, how to store to varbinary column in MySQL? public_key = '67498930589635764678356756719' or public_key = 67498930589635764678356756719 Will the second method work? I am into an emergency moment working on a production server and didn't want to experiment on it. Thank you ...

Can't connect to local MySQL server through socket

i m getting error on my site when i upload it. on submitting some pages error comes mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) what means by this? ...

problem with mysql query when password like \/'

In mysql table name (user_login) and i having field like login_name and password . I entered in login_name as abc and password as \/'(Special symbols like \ / ') .And my query is select password from user_login where password like '\/'' and I got sql syntax error ...

MySQL "ON DELETE CASCADE" is too powerful

hey, following problem here: i have table with persons that have one location, if i delete the location for the location table, i don't wont to lose the assigned persons. ive a entry in the location with the id=1 and the name is: "No location". and that what I'm trying to do, but i fail! ALTER TABLE `persons` ADD CONSTRAINT `persons_i...

How to use foreign keys and a spatial index inside a MySQL table?

Hey! Our project keeps world data base in tree-structure inside INNODB table of MySQL db. Earth is the root, then countries, then country regions and the locations are the leaves. A foreign-key is used to provide a fast access to children (for example cities in a region). Now we want to implement a fast geo-search in the data-base for...

[Mysql] Inline Query vs Stored Procedures to use in PHP

I have been using inline query statements within my model of my application... As of now many people said that stored procedures would be a good practise... I have the following question How to use MySql stored procedures in PHP Codeigniter? What are the advantages of using Mysql stored procedures? ...

what is the best way to parse big JSON file and insert into database using php?

I have this huge JSON file. Currently the way I am using it is: Read the entire contents into a string Do json_decode, get the array Loop through the array one record at a time and build my SQL insert statement Problem is, the code is ugly. Also, some of the objects in these arrays are themselves arrays, and not all records contain...

MySQL GROUP BY two columns

Hi, I'm trying to group by multiple columns here - one on each table. It's a scenario where I want to find the top portfolio value for each client by adding their current portfolio and cash together but a client may have more than one portfolio, so I need the top portfolio for each client. At the moment, with the code below I'm getting ...

sub query returning more than one row

I am trying a query like this in MYSQL select Sum(case when WindowsXP = "PASS" then 1 else 0 end) as PASS , Sum(case when WindowsVista = "FAIL" then 1 else 0 end) as FAIL from OS_Table where BuildID = (select distinct BuildID from OS_Table) group by BuildID The error is Subquery returns more than one row. If I use IN instead of = t...

MySQL database corrupted

My INNODB database corrupted somehow.I have no backups of that database. When I click on the database tables in question they come up with: (#1033 - Incorrect information in file: './resafari/properties.frm') anyone have any solution for that ? please help me. ...

copy mysql blob field from one database to the other

Hi! I happen to have a database with pictures stored as blob fields. Can't help it, it was the previous developer's choice. Now I need that data in a new site and the provider won't let me copy the data the easy way (file has become 11Mb big - won't upload that and I don't have shell access). So I thought I'd write a script that opens...

Python database access using single file/already build file

Hi everyone! I have to save some data into MySQL from Python. I have tried MySQLdb, but it needs to be built. Build fails on my Mac; moreover, I need to have one file to copy to server. I don't have access to install anything. Can you recommend me any solution, please! Even where I can find MySQLdb build for specific platforms. Thank...

Can I import tab-separated files into MySQL without creating database tables first?

As the title says: I've got a bunch of tab-separated text files containing data. I know that if I use 'CREATE TABLE' statements to set up all the tables manually, I can then import them into the waiting tables, using 'load data' or 'mysqlimport'. But is there any way in MySQL to create tables automatically based on the tab files? See...

Small Php and MySql problem

I have an array of ID:s, and the ID:s are in this format: Bmw_330ci_89492822 So it's a string! Now, I have this code to find whatever is in that array, in MySQL: ($solr_id_arr is the array I mentioned above, it contains string ID:s) ex: $solr_id_arr[0] outputs Bmw_330ci_89492822 $solr_id_arr_imploded = implode(", ", $solr_id_arr);...

How to code in OO PHP?

How can I do this in OO PHP: A form ('in newstudent.php') asks the user to enter his name, course and year. After selecting 'Submit' button, the page will go to 'records.php' records.php - contains a table that displays all the records (columns: name, course, year) when the user selects 'Submit', the new record will be added to the dat...

Sort by order of values in a select statement "in" clause in mysql

I'm selecting a set of account records from a large table (millions of rows) with integer id values. As basic of a query as one gets, in a sense. What I'm doing us building a large comma separated list, and passing that into the query as an "in" clause. Right now the result is completely unordered. What I'd like to do is get the resu...

MySQL 1064 error, works in command line and phpMyAdmin; not in app

Here is my query: select * from (select *, 3956 * 2 * ASIN(SQRT(POWER(SIN(RADIANS(45.5200077 - lat)/ 2), 2) + COS(RADIANS(45.5200077)) * COS(RADIANS(lat)) * POWER(SIN(RADIANS(-122.6942014 - lng)/2),2))) AS distance from stops order by distance, route asc) as p group by route, dir order by distance asc limit 10...

MySQL Split to use in "SELECT WHERE IN" statement

I've been scouring various MySQL sites in the hope of finding something that will allow me to turn this: var parameters = "a,b,c,d"; // (Could be any number of comma-delimited values) Into this (assuming that my parameters are somehow becoming the values you see in the IN block): SELECT * FROM mytable WHERE parametertype IN('a', 'b',...

Properly formatted MySQL date insert statement returns all 0's

I've created a PHP script that parses an HTML page, creates a MySQL query, and inserts the parsed data into a MySQL table. Everything works fine, except for one thing : the date field. When PHP runs the MySQL statement, the dates in the table read 0000-00-00 . If I echo the MySQL query, it results in the following : INSERT INTO dispatc...