mysql

Need to know if this is possible with SQL and if so, how to do it

Here's my current query: SELECT questions.question, questions_headings.title FROM questions JOIN questions_headings ON questions.heading=questions_headings.id WHERE questions.heading IN (1,2,3) ORDER BY RANDOM() LIMIT 10 Basically, the database contains Questions for various Headings. For example: questions_headings: +----+-------+ ...

MySQLdb install problem.

I need to install MySQLdb. I write: $ tar xfz MySQL-python-1.2.1.tar.gz $ cd MySQL-python-1.2.1 $ python setup.py build #it is ok $ su root setup.py install #return list of errors error list: setup.py: line 3: import: command not found setup.py: line 4: import: command not found- setup.py: line 5: from: command not found-...

WHERE all IS NOT NULL

Hi, how can I run a MySQL query that selects everything that is not null? It would be something like SELECT * FROM schedule WHERE ((all)) IS NOT NULL Do I just remove the all and go..? SELECT * FROM schedule WHERE IS NOT NULL Thanks! ...

Assigning xml generated by a while loop to a variable

Hi guys, I am creating XML using a while loop, but now I need to prepend and append the generated XML with the XML header info and wrapper tag, but I am struggling to get it to work, here is my code, $result = mysql_query("SELECT * FROM users") or die(mysql_error()); $row = mysql_fetch_array($result); while ($row = mysql_fetch_arr...

Multi user - Drag&Drop

Hi! I have a tree ful with data that are draggable (& droppable). It all works fine, but there's one problem. When more users're working on this module (with tree) and they're dragging objects around, all get mixed up. So I'm working on a solution, but I got as far as table lock in mysql. But if I do that, just one user can work on thi...

I want to create more triggers on the same table

I have 2 tables that I want to be synchronized when insert, update or delete can I create more than one trigger on the same table?? I already wrote code like that .. but it doesn't work .. but when I create only one trigger it works correctly. the code is something like that: CREATE TRIGGER photosinsert BEFORE INSERT ON photos FOR ...

How do I solve an advance filter problem, using MySQL query

Hi, I would like to know a solution which can help me generate a MySQL query to fetch data as I want from a single data base table. Table name: Rates Columns: id, date, weekday, costA, costB, costC, sellA, sellB, sellC SAMPLE TABLE DATA ================= id | date | weekday | costA | costB | costC | sellA | sellB | sellC --------...

PDO positional and named parameters as part of the same prepared query?

I'm learning the ropes with PDO. Here is my sql (the number of parameters that can appear in the WHERE is variable). SELECT ID, title FROM table WHERE something = ? ORDER BY :sort :dir LIMIT :start, :results Here is my code: $query = $conn->prepare($sql); ...

Changing the module that updates the currency rates in Prestashop

I am currently working on a Prestashop site. I included a new currency and then clicked on Update Currency Rate only for the system to set my new rate equal to the default currency rate. Is it possible to change the default currency converter that Prestashop is using to something that could accommodate my own currency ...

Grant a user permission to only view a mysql view

Hi, I'm using MySQL 5.1.44, let's say I have a table with records inserted by different users of my application, how can I give some specific user access to only see his records on the table? I've think about creating a view with his records but don't know how to create a mysql user that only can view that view.. So, is it possible to ...

Integer comparison in mysql using an index

I need to compare integers in a mysql table. Pretty simple, but this table is fairly large... so queries take a long time. No problem, I can use an index. According to MySQL documentation, I should be able to use an index for comparison operators: "A B-tree index can be used for column comparisons in expressions that use the =, >, >=,...

Get a resultset from a mysql transaction

Hello I was wondering if it's possible to get the resultset of the select query from my transaction. Mysql returns that the table was updated, but returned 0 rows. This is the transaction: START TRANSACTION; SELECT *, @A:=id FROM mailer_log LIMIT 0,10; UPDATE mailer_log SET picked=1 WHERE id=@A; COMMIT; ...

[Problem Solving] PHP while loop and table header only showing if a db value is set..

Hey everyone. Here is my code. <table border="1" style="width:800px"> <?php $schedule_db = mysql_query("SELECT * FROM schedule WHERE '00:00' is not null and '01:00' is not null and '02:00' is not null and '03:00' is not null and '04:00' is not null and '05:00' is not null and '06:00' is not null and '07:00' is not null a...

Optimise SQL query joined on DATE(datetime) = date?

I have two tables: one has a datetime column, the other has a date column. I want to join the two tables like this: SELECT t1.dt, t2.d FROM table1 t1, JOIN table2 t2 ON DATE(t1.dt) = t2.date But obviously, this kills the index on t1.dt. What's the best strategy to get around this? The simplest approach would be to add a ne...

(Mysql) How to mark different WHERE OR rows?

For example i have requested: WHERE (friend_id=? OR client_id=?) How do i know which row meets friend_id condition and which meets client_id condition? Is it possible to mark/flag rows depending of meeting condition somehow? Thanks. ...

What could be the join query for the condition given below?

I have two tables Orders table and customers table, both have customerid as common field, customer table have firstname, lastname, phone and email address fields. Now if I have to search/select the orders according to customer firstname and/or lastname and/or phone and/or email and/or orderid, then what should be the mysql format of ...

concurrent users can a Apache + PHP solution support

How any concurrent users can a Apache + PHP solution support? Please don’t be bogged down by Mysql constraints – we are using LAP without M as we are storing around 2-8 PB at the back end. ...

Single text field used for different keyword (one at a time) for search

I have to use a single text box to use for search by order id or first name or last name or phone or email address, how can i Identify the input value to be related to required fields, if u have the idea to make it happen plss guide me... I have this type of query to be executed when keyword found. select orders.* from orders join cu...

Hibernate disable Query Cache

Following problem: I create a Query to display all Entries of a MYSQL Table, if I edit a Field and execute the Query again I get the same (old) Result as in the first query. It seems that Hibernate caches the Result. I tried to disable Caching with query.setCachable(false) "hibernate.cache.use_second_level_cache" "cache....

What's the best practice to denormalize in CQRS?

I am trying to create a deamon to denormalize my Database. I use ActiveMQ as queue manager I have 2 data bases: Relational one (write + replication), and denormalized one (for reads) My question is what's the best practice to denormalize my real DB I have some ideas: MySQL proxy (with lua) which reads the Queue (is this possible) Tri...