Select the same columns from a list of tables

I am looking to run this query on a list of tables. SELECT Description,Code,count(*) as count FROM table1 group by Description,code having count(*) > 1 I will have to run this query on 30+ different tables, I was wondering If I could change the from

Android Web Service Insertion Database

I created a web site of travel with symfony2, I want to create mobile application using web services created in the web site, I get the data using jsonarry and jsonobject ,how I can insert data using my mobile application. if there is good library. t

Indexing utility in a sorted data set

I have a table with the following field in my DB . Date/Time , Device ID , Sensor 1 Value , Sensor 2 Value . This is part of a IOT project where e sensor will send data to the DB every second for data analytics purposes We initialy set Device ID as a

Select with an internal join

i need select some data from two tables , please help me use inner join for this selection . players in selction2 must not be in selection1... first select : $rs = "SELECT * FROM `player` WHERE `status`=1 AND `credit`>=1 AND `username` NOT LIKE '$

Mysql count has joined fields

I have 3 tables: accounts, comments and followers In account I track user info, in comments their comments and in followers, who are they following. I want to create a query where I get basic info of the account, a count of comments and a count of fo

Replacing string in sql query

This is how I retrieve data select myPlan from myTable this is result , myPlan ===================== True , False , True False , True , False False , True , True In each row , I have three Boolean value separated by comma . The first Boolean value re

error # 1452 - assign FK twice for the same PK

I got this error - #1452 - Cannot add or update a child row: a foreign key constraint fails. I guess is I try to assign multiple foreign key to a primary key, or it is not? my table look like this user ===== uId (PK) friend ====== uId (FK of user.uId

Data type to store pdf to sql table

I would like to insert a pdf into a column of a sql table. I have defined a varbinary(max) datatype for this column. When I open this pdf in notepad++, it starts with something like this %PDF-1.6 %äãÏÒ 1 0 obj [/PDF/ImageB/ImageC/ImageI/Text] endobj

Multiple table joined with condition of a table

I apologize in advance if something like this has already been discussed elsewhere, but if it has, I was unable to find it (I'm not even sure how to search such a thing). I'm trying to join two tables, "employees" and "leave." I want t

How to optimize MySQL queries that have calculations

I have a fully working query but it takes 1.5 secs to load. I am pretty new to MySQL so I know my queries are not the best but is there a way to optimize this? I will be having 5-6 of these queries and it'll take over 10 seconds to load them all. Sel

Log off while deleting the account

Many websites I've created have user data stored in sessions for quick access. The problem is that if an Administrator chooses to delete or disable a user's account, as long as they have their session cookies they're still technically "logged in.&quo

SQL self join query

I have four tables: Service (serviceId(PK), serviceTypeId, capacity) Facilitator (facilitatorId(PK), facilitatorName) ServiceType (serviceTypeId(PK), serviceType) ServiceFacilitator (serviceId(PK), facilitatorId(PK)) (join entity) The service types i

Limit results in SQLite

I have two tables, customers (with columns A, B) and orders (with columns C,D,A; the last one a foreign key). This query returns the data I'm interested in: SELECT customers.A, customers.B, orders.C, orders.D FROM customers, orders WHERE customers.A

How do I write this SUM query in sql?

I have two tables Operators table proportion, name, routeid (proportion hold % value e.g 100 = 100% or 50 = 50% this shows the % of services ran by this operator) route table routeid, frequency (frequency holds number of trains per hour) What I need

Should I use a constraint or trigger?

I hava a Customer table, which has a column to show whether the customer is "AllowRefund", and must have a column By_Which_Staff to indicate which staff credits the privilege of "AllowRerfund". My requirement is: Before I put the staff

Selecting a column value in LINQ TO SQL

I have query in link to SQL like this var password = (from userAccounts in myDb.Physicians where userAccounts.Phy_UserName == txtUserName.Text select userAccounts).FirstOrDefault(); I want to select a specific column with that query, I want to retrie

How to convert rows into columns in an indexed view?

I use OUTER JOIN to get values stored in rows and show them as columns. When there is no value, I show NULL in column. Source table: Id|Name|Value 01|ABCG|,,,,, 01|ZXCB|..... 02|GHJK|;;;;; View: Id|ABCG|ZXCB|GHJK 01|,,,,|....|NULL 02|NULL|NULL|;;;; T

IF () alternative statement in SQLite

I have the code for MySQL (perl): UPDATE pages SET rkey = rkey + 2, lkey = IF(lkey >= $key, lkey + 2, lkey) WHERE rkey >= $key I need to use this code with SQLite, but there is no support of IF() function. What I can do?For generic SQL you can use C

Using CASE to select a field in SQL?

Based on if one field in the database is equal to something, I want to select the value of another field. I was thinking that I could use CASE THEN but I can't get it to return the value of a field. Here is what I have tried so far: SELECT LastName,

SQL SUM of distinct lines and hellip; I am stuck!

Been trying to put together an SQL query that sorts data into financial years (which I've sorted) and then SUMs it according to each distinct value in the claim_id column table structure is: claim(id, claim_id, date, amount) SQL so far is: SELECT CAS

TransactionScope and Transactions

In my C# code I am using TransactionScope because I was told not to rely that my sql programmers will always use transactions and we are responsible and yada yada. Having said that It looks like TransactionScope object Rolls back before the SqlTransa

How to use the LIKE condition in SQL with a numeric field?

I'm using this query to get some specific data: "select * from emp where emp_name LIKE 's%'"; emp_nam is character field, how can I use the same logic condition with numeric field? something like: "select * from emp where emp_id ???? where