mysql

Setting up application privileges in MySQL

Say you created a blog application, and it's data is stored in a MySQL database. In your application configuration you set the data source name to myBlog user root password whatever Now, when users start using your blog to access, post to, and comment on threads, etc... I am assuming they connect as root through the application myblog ...

Python and MySQL compile version

How do I check if my python and mysql are 32 bit installations or 64 bit? ...

"LIKE" in mysql

I have written a simple mysql search form that searches between two dates. This query working perfect: $sql = "SELECT * FROM table WHERE dateStarted like '%$checkin%' AND dateEnded like '%$checkout%'"; But with $sql2 = "SELECT * FROM table WHERE dateStarted = $checkin AND dateEnded = $checkout"; There is no any result? What is...

SQL Data Type to store Product versions

What data type should i use for a SQL column to store Product version eg. Version 0.1 0.1.1 0.2 1.1 1.1.647 2.0 ..... In query i should be able to sort them based on version number and i want an optimal query to find highest number. Thanks ...

Problem Inserting Multiple Arrays into Database

Hello everyone, I was inserting multiple arrays into my database using this code: $queries_cols = array(); for($i=0; $i<count($cols); $i++) { $queries_cols [] = "('".$cols[$i]."','".$int_manha1_1[$i]."','".$int_manha1_2[$i]."','" .$int_tarde2_1[$i]."','".$int_tarde2_2[$i]."','".$h1_1[$i].$h1_2[$i]."','".$h2_1[$i].$h2_2[$i]."')"...

MySQL -> PHP -> JS/jQuery

I'm a bit confused about displaying data from a MySQL database. I would like to make a single $.getScript(''); request to grab point values if possible, but my trouble is getting it to work with multiple members. I need to grab the point values for each user by their ID number. (this is for a forum software- ZetaBoards.. basically a poin...

MySQL Alter Table Add Field Before or After a field already presant

I have this, but it doesn't work: $query = "ALTER TABLE `".$table_prefix."posts_to_bookmark` ADD `ping_status` INT( 1 ) NOT NULL BEFORE `onlywire_status`"; I appreciate it! ...

What type is used in sql for percentage ?

I know char, int, numeric, but i don't know what is used for percentage ? ...

Variables from function are undefined

I'm placing an entire pagination script into a function so I can use it more times. The code is long but there's just one part I'm having trouble with. After I call the function paginate($connection, "categories"); I use $sql = "SELECT * FROM categories ORDER BY cat_name LIMIT $start, $limit"; etc.. and I get these errors. Not...

mySQL: how to fill this questions - answers table

hi, I have 5 tables Questions_Answers AID | QID | otherStuff | Username | UserID | otherStuff Users UserID | Username Node ID | Type | UserId Questions ID | oldQ_ID Answers ID | Question_Link I have to fill the empty table Questions_Answers given the information in the other tables. The Question_An...

How to limit query results with Mysql

Newbie question: I've got an email message table that's got a message_id field (primary key field) and other fields like body, receiver_id, sender_id and parent_id. The parent_id field is what connects messages of the same thread together when user replies to a message. Right now i have a simple query that looks up all the messages un...

Do you know of an online tutorial for relational algebra/DDL statements?

I was meant to have my final exam on database management back in January, but I was too ill at the time to sit it. My resit have been scheduled for the end of August, which comes right at the crucial time where my dissertation needs to be nearing completion. Therefore I need to start my revision now as it's been a while since I last ha...

How do i optimize this query?

Hello, I have a very specific query. I tried lots of ways but i couldn't reach the performance i want. SELECT * FROM items WHERE user_id=1 AND (item_start < 20000 AND item_end > 30000) i created and index on user_id, item_start, item_end this didn't work and i dropped all indexes and create new indexes user_id, (item_sta...

how to connect two tables with sql and php

I am a bit new to sql and php so I need some help here. I created two tables and I want to establish a 'one-to-many relationship' but I can't figure out how I can give the data through the php file. Here is some code: CREATE TABLE `details` ( `details_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL, `latitude` ...

MySQL server has gone away on simple select query

Hi, since any weeks I have a problem with a simple SQL Query where from time to time the mySQL Server has gone away. But in the last time I have this crashes every day 1,2 times day. The query is very simple: SELECT ... from table where field = 'some string' LIMIT 1 The table has 15 rows and the "field" where the query selects is a...

Can't connect to MySQL Database in phpBB

I am trying to connect to a MySQL database using the mysql_connect() command however I keep getting the error message: Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://ravenwolftest.db.4292619.hostedresource.com:3306) in C:\Data\GITA\We...

Submit form button not working for simple todo list app (I'm new to CakePHP)?

Hello, I am learning cakephp, and I was just doing a simple Todo list app from a book. The app basically takes in a task from an input field, then you click 'Add Task' and the task should be added to database and then the user gets redirected to Tasks View page where all the tasks can be seen including the one they just added. In the ad...

Reducing the number of queries from 2 to 1

Is it possible to use 1 query instead 2? Or this way is better? (for speed) <? $q1 = mysql_query("SELECT name,url,id FROM gallery") or die(mysql_error()); if (mysql_num_rows($q1) > 0) { while ($row = mysql_fetch_array($q1)) { echo 'IMAGES FROM '.$row['name']; $id = $row['id']; //second query for each gallery $imgq ...

SQL/PHP: Order by highest vote from different table.

I needed to recommend to the visitor similar items to the one they where looking at. So I asked in another question for a SQL query to get items with the same categories (from a 'categories' table). The next is the correct code I'm actually using: SELECT c2.itemID FROM categories c1 JOIN categories c2 ON c1.catID = c2.catID WHERE c1.ite...

Possible to write MySQL stored procedures in ruby?

I have heard that one in PostgreSQL could write stored procedures in ruby (also python/java/c++). Is this possible in MySQL? Because I dont want to learn their own language for it. Thanks ...