mysql-query

Mysql query help

My system consists of two user types - Students and Tutors. - Tutors can create classes and packs - Both Students and tutors can purchase classes and packs Following are the tables involved Groups Users- Contains common fields of both user types Tutor_Details- Tutor specific fields WebClasses - Classes created by tutors Learning_...

MySQL match existence of a term amongst comma seperated values using REGEXP

Hi There, I have a MySQL select statement dilemma that has thrown me off course a little. In a certain column I have a category term. This term could look something like 'category' or it could contain multiple CSV's like this: 'category, bank special'. I need to retrieve all rows containing the term 'bank special' in the comma separat...

query to imlement block list....

Hai all, I have two tables a and b as follows to implement a simple block list where users can block other users..... Table A +------------+--------------+------+ | Name | phone |userid| +------------+--------------+------+ | Mr Sasi | 01225 708225 | 1 | | Miss Brown | 01225 899360 | 2 | | Mr Black | 0138...

Advice on structuring or normalizing my MySQL data needed

I'm building a web application and I just received some basic foundation data from the client in a spreadsheet. I need to get the data into a MySQL database in a meaningful way so I can effectively query it later. What makes the most sense? Here's the particulars: There are Departments, Classes *edit (classes are types of products like ...

Why does this left outer join query refuse to complete in phpMyAdmin?

EDITED: so the query does work, but on my localhost machine it took over a minute to run. Admittedly the tables are considerably larger on my localhost (about 8000 rows each), but in production the tables could have upwards of 25,000 rows each. Is there any way to optimize this so it doesn't take as long? As indicated in one of the comme...

Trouble structuring MySQL query with one-to-many over multiple tables

I have a blog-style app that allows users to tag each post with topics. I keep this data in three separate tables: posts (for the actual blog posts), topics (for the various tags), and posts_topics (a table that stores the relationships between the two). In order to keep the MVC structure (I'm using Codeigniter) as clean as possible, I...

MySQL query case insensitive

in my table , I have firstname and last name , few names are upper case ,( ABRAHAM ) few names are lower case ,(abraham) few names are character starting with ucword (Abraham) So when i am doing the where condition using REGEXP '^[abc]' ,am not getting proper records, How to change the names to lower case and use SELECT QUERY , ...

Selecting a column that is also a keyword in MySQL

For some reason, the developers at a new company I'm working for decided to name their columns "ignore" and "exists". Now when I run MySQL queries with those words in the where clause, I get a syntax error; however, I can't seem to figure out how to reference those columns without running into an error. I tried setting them as strings, b...

Mysql benchamrking GUI tool

Hi I need to optimize an application which is already there for a long time. Optimization will include move inline queries from php pages to "stored procedures", get rid of sub queries and convert them to "joins" etc etc. I guess the best way is to use benchmarking tools for this purpose, but is there any GUI based tool available which ...

PHP/ MySQL: Query not processing (syntax error near x on line 1)

Hey... so I attempted to run the query below and it just won't do it. I've checked: The number of fields in the form matches the number of fields in the table. The number of session variables matches those numbers too. That the actual query contains the data to be input with an echo. That the table name is correct. That queries work wi...

Problem searching MySQL table using MATCH AGAINST

Hi there, I have a MySQL table containing event data. On this table, I have a FULLTEXT index, incorporating event_title,event_summary,event_details of types varchar,text,text respectively. Examples of titles include: "Connections Count", "First Aid", "Health & Safety". I can search the table as follows: SELECT * FROM events WHERE MA...

sql query to show the name of table in a database

i use "SHOW TABLES STATUS" but what i got only number of table in database ? ...

Remove duplicate text from field

I am wondering if it is possible to remove duplicate text using a mysql query from one field, or if a problem like this would be better solved using PHP. I have a database where users enter tags which can be searched upon. I have noticed that some tags have synonyms which I want to add to the field, but in some cases the synonym already...

how to optimize a left join query?

I have two tables, jos_eimcart_customers_addresses and jos_eimcart_customers. I want to pull all records from the customers table, and include address information where available from the addresses table. The query does work, but on my localhost machine it took over a minute to run. On localhost, the tables are about 8000 rows each, but ...

order by two columns with same priority

Hi , i have table , contain firstname and lastname , i used in my query : ORDER BY FNAME,LNAME ASC , It display the records alphabetical order , and it works fine for Fname, but it is not giving the same periority to LNAME, my present table records : No Fname Lname 1 Agh Asd 2 Arh AAA 3 Bcvc Vvcv 4 Akasa Dvxvx ...

How does MySQL evaluate Text and VarChar fields when compared to booleans?

Like select * from table where text_field; What would get pulled? ...

MySQL How do you return the UNION of these two queries??

How do you get the UNION of these two queries: SELECT dom,sub FROM table WHERE table.dom = X OR table.sub = X SELECT dom,sub FROM table WHERE table.dom = Y OR table.sub = Y dom and sub are integers, both queries return a set of integers, how do you then get the union of these two sets?? Any assistance appreciated... ...

Mysql Multiple Group Bys, order by one group by item ?

Ok, So I have a table called 'auctions' and each auction has a 'product_id' associated. The auctions table may have 500 items with repeated products. I want to order by auction_id asc (so newer auctions are shown first), but also only show distinct products. Using distinct doesn't work, and when I group by the product_id, it doesn't o...

How to select the last word in a string

I have used Select Subst(field_name, 1, Locate('',field_name)) as first_word from table_name and it works for the first word so I tried using last_word but still get the first word so I guess there must be a differet way?? ...

mysql - three joins on the same table

I have two tables: persons - person_id - fullname students - student_id _ person_id - father_id - mother_id In students table the last three columns store ids from persons table. What SELECT could retrieve the following data: - student name - father name - mother name We assume no WHERE, ORDER BY, or LIMIT for simplicity ...