0
votes
1answer
17 views

Adding a constant IF not in an other table

So I have this query. SELECT * FROM `Comment` WHERE `Target` = '".$_GET['pp']."' AND `Id` NOT IN (SELECT `Target` FROM `Delete` WHERE `Type` = 'comment') ORDER ...
0
votes
1answer
11 views

Mysql Select using Alias

I Need to filter the query that have some conditional column as below: SELECT `c`.`fullname` AS `fullname`, IFNULL(`c`.`new_ic`,`c`.`old_ic`) AS `Ic`, `bla`.`loan_no` AS `Loan_No`, ...
0
votes
0answers
6 views

Get travel_point.address_from and travel_point.address_to when driver_has_book.status is 0, 1 or 2

I'm building a view for get travel_point.address_from and travel_point.address_to when driver_has_book.status is 0, 1 or 2 (basically I'll need another data from related tables). I leave the SQL ...
0
votes
1answer
32 views

Building a query programatically

I have three variables $color, $size and $category. Each oh them can be a specific value or may refer to all entries.I want to fetch all products that are $color = "red", $size = "Medium" and any ...
0
votes
2answers
30 views

Sql statement to compare two table

I have two table with the same structure, i want an sql statement to compare them and see any modified line, deleted or added Table Product1 : ________________ |Product | Price| |Product1 | 10 | ...
1
vote
2answers
45 views

What subquery do I need to calculate this report?

I have two tables: tickets and comments. I need to run a report that shows me which ticket is "neglected" meaning that there has not been a comment in X amount of time. If I was to do this in PHP, I ...
1
vote
1answer
34 views

pass data from deleted table to another

This is the situation: I have a table, with name TABLE_1 I would like delete TABLE_1 and then create another table with the same name and some of its columns. TABLE_1 has records, but I need to pass ...
1
vote
2answers
55 views

Get only the oldest entry in a join

So I have a table bugs |bugid| title| the table is lacking a date column. But when creating a new entry, most likely always a new entry gets created in bugnotes as well saying "bug created" with the ...
1
vote
1answer
12 views

Select the last logged change before a specified time from a change list

I want to get the last change for all issues issue, that was made before a specified end time. I have 3 tables. projects +---+------------+ |ID |project_key | +---+------------+ |1 |bug_tracker | ...
0
votes
2answers
32 views

Query Cache Implementation Details

I am new to DBA stack exchange & this is my first question. Kindly help me in finding a low level documentation for Query Cache module in MySQL since I am planning to work with the source code of ...
1
vote
2answers
69 views

Restoring MySQL Tables from .ibd, .frm and mysqllogbin files

For some reason, when I try to open up my tables that are stored in .frm and .ibd files (whether on MySQL or phpmyadmin) it gives me a syntax error or it says it does not exist. I've read the other ...
2
votes
2answers
67 views

I need help optimizing a not that complicated query that returns unexpedcted performance problems

I have a table that stores details about incoming and outgoing phone calls such as when a call was made, or when a call was received, the phone number of the caller, and the phone number of the ...
1
vote
2answers
19 views

getting one day timestamp in mysql

Please consider the following stored procedure I have: ORIGINAL Stored Procedure: -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments ...
1
vote
1answer
47 views

How to make the SQL query more efficient?

I use mysql under Linux. My table is about 8000000 rows. The table has index(advertiser_id,activity_date),(activity_date,advertiser_id,activity_type). The table is looks as following: activity_date ...
0
votes
1answer
36 views

Problem with foreign keys

I do ALTER TABLE bdt.auth ADD CONSTRAINT `depositor no.` FOREIGN KEY ( `depositor no.` ) REFERENCES bdt.depositors( `depositor no.` ) ON DELETE CASCADE ...
0
votes
1answer
17 views

Creation of a simple field failed in MySql [duplicate]

CREATE TABLE bdt.transactions ( `transaction no` int UNSIGNED NOT NULL AUTO_INCREMENT, data date , by int NOT NULL , hours int NOT NULL , ...
0
votes
0answers
13 views

counting values of unread values using mysql and php

I am building a messaging system using mysql and php. I have gotten to a point where I want to select messages received by a user and also count the unread messages received from different users to ...
0
votes
2answers
34 views

What I should choose? [closed]

I'm Dentist by profession. I want to create database which will contain my all clinical information including patient's name,complaints to how much did patient paid and how is the balance and his ...
0
votes
1answer
32 views

How to join 3 tables together given 2 many-to-many relationships tables in between?

I have 3 main tables: Person, Publication and Conference and 2 many-to-many link tables in between: person_publication and person_conference I want to join all 3 main tables together (showing me all ...
1
vote
1answer
66 views

Optimizing large MySQL SELECT WHERE IN clauses

How can the following SELECT WHERE IN case be optimized? I have a table with over 100 million rows with only 3 columns. The primary key (col1) is a 127 varchar. I am performing a SELECT col1 WHERE ...
0
votes
0answers
13 views

set error message on out variable in mysql stored procedure

I have a stored procedure: fill_DATA (serial varchar(20), OUT oError) I am doing an Insert operation here. so what I want is to SET value of oError for any error message in case the query fails to ...
1
vote
1answer
35 views

How to do the complex nested select SQL?

I have two tables, table1 is as following, id is primary key, table2_id is foreign key id date aid table2_id message 1 2014-03-19 16:21:02 121 1 login from xxxx 2 ...
1
vote
2answers
41 views

SQL - query multiplying records returned - Cartesian Product

I am using the following query which is returning a huge number of multiplied records - i.e. a cartesian product: SELECT * FROM specimen, topography_index, morphology, functions WHERE ...
1
vote
1answer
20 views

How to make MySQL join one-to-many with lowest value?

I have following database structure Domain has many URL which has many positions which belongs to phrase which belongs to user which belongs to subscription. In subscriptions table I have period ...
0
votes
1answer
20 views

Want to create partitions of a MySQL table and change the charset of new partitions

I have a database table which contains large amount of data. I have written a script to create new partitions every week and drop old partitions (which are of no use). Currently, I have a column in ...
0
votes
0answers
21 views

Multiple client tables or large overall table

I've recently taken over a project linking to a large MySQL DB that was originally designed many years ago and need some help. Currently the DB has 5 tables per client that store their users ...
0
votes
0answers
21 views

Error Code: 1133. Can't find any matching row in the user table

Im reading O'Relly "Learning MySQL" and it says that you can create a user in MySQL by doing just this: mysql> GRANT ALL ON *.* TO 'jill'@'%.invyhome.com' IDENTIFIED BY 'the_password'; Query OK, 0 ...
0
votes
0answers
18 views

Auto backup only for MySql database and selected folders in WHM or via cron job command

Hell all i have a VPS, WHM provide use auto backup feature. but i want only backup some selected database and folder. i try to use command via cron job but its not working. current code (not ...
0
votes
1answer
10 views

MYSQL testing string field contains another altered string field

I have this table : mysql> desc mytab; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | ...
0
votes
0answers
17 views

Select changes in table by date

I have following table schema name type id int key string count int date date url_id id with example data id key count date url_id 1 system 100 ...
0
votes
1answer
17 views

Insert pictures [closed]

I need to create dictionary with pictures. I created database of words in mysql I tried to collect pictures of each word. How can insert pictures into tables?
0
votes
0answers
20 views

Installing database

I have created database in my system using mysql.I tried to use in one of my friend's system.How can install the database in other system?
0
votes
0answers
26 views

eCommerce product table design - MySQL

I am designing database for an web application, I have designed the product and specification details database as follows, create table pr_size ( size_id int not null auto_increment, ...
0
votes
0answers
13 views

Redesign tables, multiple foreign key and related table to same table

Hello I have this database: Table Teams is used in each one table. Match table contains teamA and teamB and round contains team that win the SET and team that start the set. But I dont know how I ...
0
votes
1answer
9 views

Get devices with not driver assigned

I have this related tables: And I need to get those devices with no driver assigned, in other words the device returned on this query shouldn't be on driver_has_device table since it'll not have ...
-1
votes
4answers
205 views

Database/Storage engine suggestion for a project involving heavy inserts?

I am looking into a project which involves large number of inserts daily.I will have a list of user's (for example a user set of 500k ) , for which I need to monitor daily certain activities ...
1
vote
2answers
59 views

Checking if an Username is already in use

I am writing some scripts for my website, and I am currently focussing on checking if a username is already in use. I have tried writing a SELECT script where the datafield is selected and checks if ...
0
votes
1answer
54 views

What is a good/healthy mysql query execution time?

What is a good/healthy mysql query execution time? To my calculations: The site gets 1000 unique visitors per hr 10 page view for each unique visitor 5 minutes for each unique visitor ...
0
votes
1answer
34 views

GROUP BY performance

I have a query like this: SELECT HOUR(datetime) as Hour, COUNT(*) as hits, SUM(clicks) FROM visitors_log_table WHERE datetime >= CURDATE() GROUP BY Hour WITH ROLLUP It works fine. But I ...
1
vote
3answers
76 views

Block user access to certain tables

DBMS allows the admin to grant table access to a user using something like: GRANT ALL ON mydb.mytbl1, mydb.mytbl2 TO 'someuser'@'somehost'; However, is it possible to grant all tables to a user and ...
0
votes
0answers
13 views

Checking for records in lookup table before deleting

In my MySQL database, I have products table, a locations table and a lookup table (called location_products) where the ID of the product and ID of the location are stored. I am creating a transaction ...
0
votes
2answers
40 views

“GROUP BY” in ranges?

Suppose I have a table with a numeric column (lets call it "score"). I'd like to generate a table of counts, that shows how many times scores appeared in each range. For example: score range | ...
0
votes
1answer
29 views

Msg 2627 Violation of PRIMARY KEY constraint

trying to make a database for teams in a tv show here. but when I try and insert data into tblShowteam the following error made its appearance. Msg 2627, Level 14, State 1, Line 2 Violation of ...
0
votes
0answers
14 views

Specific id to appear first in result of query [duplicate]

I have a sample query where: Select gID, entID, cID, gString From tblGF Where ((entID=$entID And cID=0) Or (entID=$entID And cID=$cID)) And (gFP='BB' Or gFP='CP' Or gFP='PS' Or gID=$gID) Order ...
0
votes
0answers
15 views

Would an INNER JOIN query in a sharded relational database hit the same shard when using a compound primary key?

In this question I have asked about modulus calculation in sharded tables, this design is used: CREATE TABLE Orders (order_id INT PRIMARY KEY, ...); CREATE TABLE LineItems (order_id INT, lineitem_id ...
0
votes
0answers
9 views

Modulus calculation for compound primary keys in MySQL Cluster (and other sharded databases)

In MySQL Cluster, and generally in sharded databases, how is a compound primary key's modulus calculated? Say, for example, there are two tables that have primary keys like so: CREATE TABLE Orders ...
0
votes
0answers
20 views

Indexed column INSERT vs. UPDATE

I have an indexed column. I could give it a value on INSERT. But it would be easier if I would add this value via UPDATE later (I have to update this row anyway). But I was thinking if it would be ...
0
votes
1answer
49 views

Need help optimizing query to prevent full table scans

I have the following query, which while it works, is also doing a full scan on each left joined table (the log* tables). I thought by using a subquery in the FROM that this would eliminate the ...
0
votes
1answer
34 views

COUNT and GROUP BY performance

I have a table where I store visits (id, datetime, country, browser). I want to count how many visits are from which country. I use this query: SELECT country, COUNT(*) as hits FROM hits_table ...
0
votes
1answer
47 views

Join 3 tables returns too many results [closed]

I have 3 tables: users, posts, videos. The last 2 tables have user_id that associate with users.id (first table). The problem is that when I try to run inner join query and return all posts and ...