mysql

SQL Performing a search/replace search

I need to search a specific column for every occurrence of a string and replace it with a different string. The column is a MySQL TEXT column. ...

can i change the default encoding of my mysql server from latin-1 to utf-8 ?

can i change the default encoding of my mysql server on my computer from latin-1 to utf-8 ? ...

MySQL Database; best schema

I have a question about a database schema for a certain website where people can sell and buy stuff. When someone adds an ad to the database, he will choose the category and fills out the filters that belong to the selected category, so anyone can easily find his ad by browsing to a category and choosing filters like: [bluetooth] ye...

SQL to update a table only if that table exists in the database

I have a mySQL database that might have a table named jason. A separate instance of the database may not have the jason table (it would have other tables in common) I'd like to run a simple update against both databases but the update is for the jason table. I know I can do something like DROP TABLE IF EXISTS `jason`; Is it possible...

How to benchmark php/mysql site

I would like to know how to benchmark a php/mysql site. We have a web app almost completed and ready to go live, we know how many people are going to be using it in a years time but have absolutely no idea how much bandwidth the average user takes, to how much time they burn up on the database etc. We need to determine the correct serve...

DECIMAL vs INT what is the best optimized choice?

I'm sure this ask in incomplete without a precise context, so I'll try to explain it, and I'll try to be clear I need to store a whole of data rapresented on the page with grams, milligrams, micrograms and kilojoule. All of this data is like 99999.99g (kilojoule apart), so I could use DECIMAL(7,2) or DECIMAL(5,2) with older MySql versio...

Copy table without copying data

CREATE TABLE foo SELECT * FROM bar copies the table foo and duplicates it as a new table called bar How can I copy the schema of foo to a new table called bar without copying over the data as well? ...

mySql problem in MySqlDataReader

MySqlDataReader rdr = cmd.ExecuteReader(); i have a some information in my mysqldatareader. how can i show it on our web-pages I don't know how i can use it .it means mysqldatareader. also welcome for simple source code. ...

Need HELP in converting MySQL to MySQLI in my PHP script?

I need some help in converting my script from using mysql to mysqli I have been trying for ever to do this and keep getting errors I have read articles on how to do this and still can get it to work. Here is the original working script below. <?php require_once ('./mysqli_connect.php'); // Connect to the db. if (isset($_POST['submitt...

Slow query - Multiple joins and a lot of data

I'm sure there is a better way I could be doing this. I have three main tables with large amounts of data to run through: records_main, sales, and appointments. Each with close to 20,000 records. I need to join these three tables as well as a few others that arn't two large. $SQL = "SELECT DISTINCT appointments.id AS aid, appointme...

Best way to learn MySql

i want to learn mysql. what i do for learn it. Currently i Read books on MySql. any other way for learn it ...

Quick Left Join Question

I have this straight forward query: SELECT f.id, f.format_type, h.newspaper_id FROM newspapers_formats f LEFT JOIN newspapers_formats_held h ON (f.id = h.format_id) This returns all format_types, format ids, and the newspaper id that we have for that format. What I need is to then limit it to only newspaper_id = x, however, if I do th...

PHP and MySQL warning question Help?

I have been trying to convert my script from mysql to mysqli and during the process I got the following error listed below. Warning: mysqli_query() expects parameter 1 to be mysqli, string given in on line 41 Warning: mysqli_error() expects exactly 1 parameter, 0 given in on line 43 Here is the full code below. <?php require_once (...

sql select to start with a particular record

Is there any way to write a select record starting with a particular record? Suppose I have an table with following data: SNO ID ISSUE ---------------------- 1 A1 unknown 2 A2 some_issue 3 A1 unknown2 4 B1 some_issue2 5 B3 ISSUE4 6 B1 ISSUE4 Can I write a select to start showing records...

auto increment with a string of numbers and letters

Right now im using auto increment to identify resources in my website. The problem is i dont want the users to know how many resources there are. How could i instead use some kind of structured "random" combination of letters and numbers (say 6 digits) that i could use instead of (or in addition to) the auto incrementing primary key nu...

MySQL to SQL Server transferring data

I need to convert data that already exists in a MySQL database, to a SQL Server database. The caveat here is that the old database was poorly designed, but the new one is in a proper 3N form. Does any one have any tips on how to go about doing this? I have SSMS 2005. Can I use this to connect to the MySQL DB and create a DTS? O...

One ID for every database column, how to do?

I working on a food database, every food has a list of properties (fats, energy, vitamins, etc.) These props are composed by 50 different columns of proteins, fat, carbohydrates, vitamins, elements, etc.. (they are a lot) the number of columns could increase in the future, but not too much, 80 for extreme case Each column needs an indiv...

sql complex like expression @user

im trying to find all the mentions for the matched username (sam) from the database text code with following: $sql = "select * from tweet where feed like '%@sam%'"; this will return all the rows which user have been mention at. but now the problem is, it also returns rows with @sam3, @sam-dadf or anything that is after @sam.. how c...

How to concatenate parameter in query

I want to use a parameter in the following query, but I am not really sure how to. If you can help me, I will be greatful. $id will be 1, 2 or 3 etc. and I want to select where C.Name is Galleri1, or Galleri2 etc. This is what I got so far, but I am not sure how to add $id. function getGallery($id){ $data = array(); $Q = $this->db...

restart multi-threaded perl script and close mysql connection

I have a Perl script that reads a command file and restarts itself if necessary by doing: myscript.pl: exec '/home/foo/bin/myscript.pl'; exit(0); Now, this works fine except for one issue. The thread that reads the command file does not have access to the DBI handle I use. And over a number of restarts I seem to build up the number o...