mysql

Are all MySQL joins selections on the Cartesian product?

On reading the documentation of the MySQL join commands, it looks like all the joins are analogous to , by simply finding the Cartesian product and then selecting from that result. Is this an accurate assumption? Should I instead write my own sub-queries and select from those? ...

What prior knowledge do i need to have about socket programming?

0 down vote favorite I have to design GUI for authentication. Which will have 1. User name 2. Password using The stream socket, The packet socket or The raw packet.is it possible in php and mysql language. any references or tutorials? ...

MySQL Left Outer Join with Count from joined table, Show all records

Hi All, i am trying to create a query where there is a count of related records from another table. I'd like the "parent" records whether there are related records (a count) or not. SELECT r.region_name, r.region_id, r.abbreviation, r.map_order, (IFNULL( COUNT( p.property_id ) , 0 )) AS propertyCount FROM `rmp_region` r LEFT OUTER ...

How can I select the latest of three value types in a MySQL database?

Here is an example table: ID time data type 0 0100 xyz 0 1 0200 xyz 1 2 0300 xyz 1 3 0400 xyz 2 4 0200 xyz 0 5 0500 xyz 2 6 0300 xyz 0 Data is added based on timestamp so that the last of each type has the latest time stamp. I would like the result of a SELECT to b...

How to optimize a query that's using group by on a large number of rows

The table looks like this: CREATE TABLE `tweet_tweet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(256) NOT NULL, `created_at` datetime NOT NULL, `created_date` date NOT NULL, ... `positive_sentiment` decimal(5,2) DEFAULT NULL, `negative_sentiment` decimal(5,2) DEFAULT NULL, `entit...

How to make a variable LIMIT in a query, using MYSQL

I'm trying to build a query with a variable limit. As far as I know I cannot do something like select * from table limit my_variable;, but I've read on the internet about a workaround: SET SQL_SELECT_LIMIT = variable; I have to write this syntax before the query I want to apply the LIMIT in. This works fine if I write a SELECT query a...

Multiple Adsense ads on one website - avoiding SQL injections

I'm working on a website where members can post their own adsense banners onto the site. Initially I wanted to use the Adsense API to share revenues with users. (They would just have to enter their Adsense publisher ID) but I found out that I don't meet the requirements to use the API. My alternative is to allow users to submit their en...

mysql left join but return blank row

Hi, i have a small problem where i have this setup... Table: trade names { trade_id : 1 trade_name : olivers guest house} Table Customer { name: me, trade_id: 1 : blah: blah} i do a left join to get the trade name into customers as if you are a guest house you will have a trade name but as a landlord you will not have a tr...

MySQL UPDATE - Selective update - continued

I have a query (source)... UPDATE covers t LEFT OUTER JOIN (SELECT cover_id FROM covers ORDER BY cover_views DESC LIMIT 10) c ON c.cover_id = t.cover_id SET cover_views = 0 WHERE c.cover_id IS NULL ...which resets all but the top 10 covers in the database to 0. I want to extend this to reset all covers bar the top ten per c...

using mysql min() find next lowest value

Hello, I have a script to find the lowest value from a column but some entries dont have a value or its set to 0 if this is the case I'd like ti to find the next lowest value. Here is my sql command. $result = mysql_query("SELECT DISTINCT product_name, format, image_url, MIN(online_price), EAN FROM products where $searchstring and form...

Importing fixed-width text files to Mysql with PHP

Hey all, I'm trying to import fixed with text files into a Mysql table. I'm digging around for answers, but my main issue is that I can't figure out the logic of how I should do this. Maybe someone could offer some hints on process: Steps 1. fopen the file $file_handle = fopen("thefile.txt", "r"); 2. Use feof to go to the end o...

Need help with sql query to find things tagged with all specified tags.

Let's say I have the following tables: TAGS id: integer name: string POSTS id: integer body: text TAGGINGS id: integer tag_id: integer post_id: integer How would I go about writing a query that select all posts that are tagged with ALL of the following tags (name attribute of tags table): "Cheese", "Wine", "Paris", "Frace", "City"...

Need help with sql query to find things with most specified tags

Let's say I have the following tables: TAGS id: integer name: string POSTS id: integer body: text TAGGINGS id: integer tag_id: integer post_id: integer How would I go about writing a query that selects all posts in order of the post containing the highest number of the following tags (name attribute of tags table): "Cheese", "Wine...

Why doesn't this mysql IN (1,2,3,4...) condition work if there are many values in the parenthesis?

I am storing in a column a list of states that are separated by commas: Like this: 1,2,3,4,5,6,7,8.. and so on, just their IDs. Then I am doing a query to get all the rows that have the state with the ID 8, and it works when the list of states has few items. This is the query and the table: mysql> select id_partner, name, states from...

Backup of a mysql database which is not running anymore

Hi, after a system failure, I have only limited access to the server. Question is, where does msyql store the database(s) and is it enough to just copy the files, or is anything else needed? I think I already spotted the databases @ /var/lib/mysql ... is it enough to backup these files & re-use them with a newly created database? ...

MySQL Cluster transaction isolation level - READ_COMMITTED

Hello, I'm a beginner. I'm learning by mostly reading the documentation. Unfortunately, http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html#isolevel_read-committed doesn't say anything, while it says everything. Confused? Me too. ndb engine supports only "READ_COMMITTED" transaction isolation level. A. It starts by saying "set...

sql make the joined tables as one table may be???

Is there any way to name the complete select as a table? I will try to explain what I am trying to do. I have this SELECT * FROM `Databse1`.`table1` JOIN `Database2`.`table2` ON `table2`.`customerID` = `table1`.`customerID` WHERE `table1`.`recordID` IN (1,2,3,4) I have another table, table3 that...

How to use the OR statement in MySQL while using the LIKE search statement

Hi, I am trying to create a good little search statement that searches muitple fields using the with different search terms depending on what is returned. I am basiclly setting an order in which I want to search if one search term is not found try the next one. However I am using a WHERE clause to seperate search only one type of data....

Unexpected index scan in mysql query plan

I'm getting an index scan on a join with a unique column; it claims to be examining a large number of rows even when it's looking up just one row. This is the query: select t.id, t.twitter_id, t.screen_name, t.text from tweets t inner join twitter_handle th on th.handle = t.screen_na...

where can I find mysql.data.dll for c#

All I keep on finding are source files for compiling the project myself (which keeps on failing). Any ideas please? Thank You! ...