mysql

How to use an sql subquery that uses count.

I have a system where reservations are stored as records in one table(workshop_reservation) and sessions (the things being reserved) are stored in another table(session). Each reservation belongs to a session, and each session belongs to a workshop. I want to make a mysql query that finds the number of reservations for each session that...

Constructing SQL query(ies) with optional parameters/ranking

Hi all, I was wondering what would be a good way to accomplish the following using mysql: Lets say I have a table that contains these fields: MyTable --------- Country [string] Region/Province/State [string] City [string] And I have the following data rows in the database Entry 1: Canada, Ontario, Toronto Entry 2: Canada, Ontario,...

Finding Domain Names from List of URL using MySQL/JAVA/PHP

Hi Friends http://en.wordpress.com/tag/1000-things-we-hate/ http://en.wordpress.com/tag/1019/ http://en.wordpress.com/tag/1030-am/ http://www.yahoo.com/index.html http://www.msn.com/index.html i am having list of domains as above in my DB, i need to get only domain name from this, how can i do that in mysql or in JAVA or in PHP ?? ...

Issue connecting to port 3306 for mysql application.

The Java application I am working with is supposed to write its resulting data to a mysql database, but whenever I run it, I get the following exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure With the following cause: Caused by: java.net.ConnectException: Connection refused Naturally, ...

MySQL remove space before order by clause

Hi all. I have a table full of "title" that I want to order by title. Problem is a lot of them have a empty space before the title. I am thinking of writting a php script to fix it all (super easy) but I was curious how could I do: SELECT * FROM products ORDER BY title But at the same time trimming the title so it doesnt order on the ...

Converting number formats between php and mysql

I'm sure this is something really simple, like a misplaced quote, but I'm completely stumped. I'm using an update query to enter shopping cart data into a mysql table, and having some major issues with card balance. The column in the mysql table is called BalanceCurrent and it's a decimal(18,2). In my php code (this is a custom Joomla co...

Problems copying Oracle result set to MySQL

Hi, What I'm trying to do is copy the result of a query in oracle into table in a MySQL database. The reasoning behind this is not important to the question, and I can't really take a different approach. What I am doing is running the query though php, then copying the result into a newly created table in oracle. I know this is not very...

CakePHP with Phonegap, can they be used together?

I want to build a phone app using phonegap that can access data on a mysql server that is backing a cakephp app. Can this be done, if yes then how can use phonegap to access data from a mysql server? ...

problem in saving url in jquery/mysql

hey guys im trying to save a url link in a html form but problem is i cant save urls like this : modules.php?name=phpBB3&file=memberlist but the result after using jquery is this url : modules.php?name=phpBB3 i heard i should use json but no idea how to do that ...

How to flag a photo as the users "profile pic"?

I'm building an app where each user can have multiple profiles. Users can upload multiple photos for each profile, etc. The folder structure will be something like public_html/ upload/ user-123/ profile-199/ profile-321/ images/ 123423.png I'm going to have a one to many relationship be...

pivot/unpivot tables mysql

can you make pivot/unpivot in mysql similar to ms sql server? thanks Here's a link to how SQL Pivot works: link text ...

PHP Sessions to handle Multiple Servers

All, I have a PHP5 web application written with Zend Framework and MVC. This application is installed on 2 servers with the same setup. Server X has php5/MySql/Apache and Server Y also have the same. We don't have a common DB server between both the servers. My application works when accessed individually via https on Server X and Serv...

MySQL Select rows where timestamp column between now and 10 minutes ago

I have a timestamp column that auto updates on insert/update. I want to get the rows that have been updated within the last 10 minutes. SELECT * FROM status WHERE code='myCode' AND 'stamp_updated' BETWEEN NOW() AND DATE_ADD(NOW() , INTERVAL - 10 MINUTE) ORDER BY stamp_updated DESC LIMIT ...

How do you handle complex data structures (OOP) in a mySQL DB?

I'll try to illustrate what I mean with an example. Say you are running a site that has users and allows posts. You have a list of users and each user has: a name a password choice of theme POSTS: - title of post - time/date of posting - post ID - array of tags for the post User ID/name/pass/theme is easy. Each variable can be a c...

Can anyone help me tame this unwieldy MySQL query before it gets worse?

I'm not very good at SQL, but I'm certainly learning. So this one provides content for a couple of lists below wordpress posts. One is, "More popular articles from this user," and the other is "More popular articles in this category." Articles can be published by editors, or submitted by logged in or anonymous users. It just checks all...

Calculate Total in a Given Row

I am developing a system where i need this: I have various rows on one table, and one of them is Total I want the script that can add the total of all the fields in the Total column. I will then add the session user so that it only calculates all total fields in that column for that particular person. You can get me the query: Exampl...

Sort JSON NSDictionary for UITableView

Hi, I am using TouchJSON to retrieve info for my app and put it in a dictionary. I would like to be able to sort it by values like difficulty and rating. How would I go about this? I have included my .m file. Thanks, enbr http://pastie.org/1091334 ...

Keeping page changes history. A bit like SO does for revisions.

I have a CMS system that stores data across tables like this: Entries Table +----+-------+------+--------+--------+ | id | title | text | index1 | index2 | +----+-------+------+--------+--------+ Entries META Table +----+----------+-------+-------+ | id | entry_id | value | param | +----+----------+-------+-------+ Files Table +----+-...

Inserting Data into MySQL Table via PHP

I'm trying to add some simple user data into a database via a webpage written in PHP, but the following code (more specifically, line three) breaks the page. Am I using the wrong MySQL function? I'm pretty sure my query is formatted correctly. mysql_query("CREATE TABLE stats ( userAgent CHAR(20) )"); $userAgent = $_SERVER["HTTP_USER_AG...

php mysql select all with same data

I have a table with 3 cols, incremeting id, name, and data What i'm trying to achieve you enter a $name... and returns $data... then it takes $data and finds all $names that have the same $data. SELECT * FROM table WHERE name ='$name' data='$data' and data!='0' does not seem to cut it.. I'm basically trying to get all rows that hav...