mysql

SQL-Query needed to find distinct IDs probably using IN and NOT IN

Let's pretend I have a large recipe-database. A table for recipes each with an unique ID and a table for ingredients with a whole lot of sets like this: ID | RECIPE | INGREDIENT ------------------------------- 1 | recipe_a | ingredient_a 2 | recipe_a | ingredient_b 3 | recipe_a | ingredient_c 4 | recipe_b | ingredient_a ...

Saving MySQL records as a series of Insert Statements

Having carefully and painfully manually populated/manipulated a series of records in a table, I want to retain them for reuse. As the table is rewritten daily I'd like to save JUST these particular records as a series of "inserts". The only way I know how to do this is to dump the whole table as sql using a GUI eg sqlyog. But is there a...

How do I get a column type "date" inserted into FULLTEXT in a mysql table?

I am making a control panel for administrators on my site that is a search function. When you enter a name it pulls the users first name,last name, email and password. When I tried to insert Birthday into the FULLTEXT to include it in the search, it is not on the drop down. I think because its type is 'date'. Is there a way around that? ...

mysql multiple queries

Query: SELECT c.Name FROM [Catagories] c SELECT c.Name, bc.CategoryName FROM [Catagories] c INNER JOIN [Business_Categories] bc ON c.BusinessCategoryID = bc.BusinessCategoryID Question: Why don't I have to put this in a WHERE clause? ...

How to avoid this PDO exception: Cannot execute queries while other unbuffered queries are active

Hi, I'd like to print a simple table in my page with 3 columns, building name, tags and architecture style. If I try to retrieve the list of building names and arch. styles there is no problem: SELECT buildings.name, arch_styles.style_name FROM buildings INNER JOIN buildings_arch_styles ON buildings.id = buildings_arch_styles.building_i...

MySQL Hibernate sort on 2 columns

I have a table as follows Table item { ID - Primary Key content - String published_date - When the content was published create_date - When this database entry was created } Every hour (or specified time interval) I run a process to update this table with data from different sources (websites). I want to display the results accordi...

SQL query against two tables

I have two tables in a MySql DB: items id (char) name (varchar) description (varchar) modified_at (datetime) folders id (int) name (varchar) parent_id (int) From a query against a search index I get back an ordered list of ids for items and folders that matched the query. For example, ("ph76gjd", 34, "rh75ghd", "gr45gfd"). O...

Is it possible to get the Model error code inside the controller in CakePHP?

I have a simple unsubscribe function in my Unsubscribed controller. if ($this->Unsubscribe->save($this->data['Unsubscribes'])) { // success $this->Session->setFlash('Your email has been unsubscribed!'); $this->redirect('/unsubscribes/unsubscribe'); } else { // error $this->Session->setFlash('There was an error!'); $th...

Pagination links do not work properly - incorrect PHP function??

Hi everyone, I am still trying to figure out how to fix my pagination script to work properly. the problem I am having is when I click any of the pagination number links to go the next page, the new content does not load. literally nothing happens and when looking at the console in Firebug, nothing is sent or loaded. I have on the mai...

How to run benchmarking on MySQL?

My server has installed MySQL Server 5.1. I would like to run benchmarking on the MySQL, but I couldn't found sql-bench, which is Benchmark Suite provided by MySQL. The MySQL Benchmark Suite seem like complicated to be install or setup into my server. I need one can be direct setup to test the benchmark without using Perl script liked ...

MySQL Replication and Upgrading an App on Master

I've got a master-slave replication setup for a suite of applications. One of those applications is a forum, which writes directly to the master. The rest just read from the slave. The forum database is huge (~10GB) which causes some issues re: backups and data transfers (even a mysqlhotcopy takes 20 minutes). I want to run an upgrade...

How to call MySQL stored procedure by using prepared statements in PHP via mysqli?

Can someone provide a working example in which stored procedure returns a recordset and is called by using prepared statemet? ...

mysql license WAMP distribute

Hi, We have a product which makes use of a portable WAMP server. If we want to sell this product to a customer, how does the licensing work in this case? Will MySQL license need to be bought? Regards. -Jad ...

How To Correct A Unique Key To Not Allow Duplicate Entries

Here is my problem: The Key "idx_SR_u_Identity_FingerPrintProfile" is meant to constrain the fields "c_r_Fingerprint" and "c_r_Profile" to be unique. It seems that I have done something wrong because all 4 entries in the table have identical values for those two fields. It is okay if two records have the same Fingerprint OR the same Pr...

how to import the attributes from one table to another in mysql

Is it possible to import the attributes of one table, then I put it into another table using a query in mysql? For example I have table1 with attributes lname, fname, mname And I want to put those attributes into table2. Is there any query that could do that? I'm imagining that the table2 has one attribute that could later be dropped ...

MySQL Select names with last names starting with certain letter

I have a MySQL database with a field Name which contains full names. To select all people with last names starting with a particular letter, let's say A for this example, I use the following query: SELECT * FROM db WHERE Name LIKE '% A%'. However, this also selects users who have a middle name starting with A. Is there anyway to alter...

Mysqld Crashes immediately on running on Windows 7...?

I am trying to run MySql 5.1 on Windows 7 Home Premium 64 bit. I have downloaded the MSI installer from the MYSql website and installed it. The installation is successful, but the service does not start. If I try to run MySql manually using the mysqld executable, it crashes immediately on running (error: mysqld.exe has stopped working)....

Rails - execute multiple queries in a single connection

How do I issue multiple SQL queries in a single database connection in Rails? My problem is, I have multiple records(about 200 or more records) to be checked with the database table's existing records(I am checking composite primary key values) I could use ActiveRecord's exists? method in a single transaction block. But I don't know whe...

Find the most recent shipment for a product (sql subselect?)

I have three tables shipment (shipment_id, shipping_date) company_order (company_order_id, shipment_id, company_id) company_order_item (company_order_item_id, company_order_id, product_id) Several companies get together and aggregate orders from a single manufacturer. This aggregate order is called a "shipment". Companies order a sele...

Is it possible through SQL injection to launch an UPDATE/DELETE statement from an INSERT/SELECT statement in MySQL?

Let's take the following vulnerable query ($id not being escaped): SELECT * FROM table WHERE id = $id Would it be possible in MySQL 5.x to modify some data through an UPDATE statement which would appear inside the hacked SELECT statement? I thought about something using benchmark() function: SELECT * FROM table WHERE id = id OR benc...