[Solved] get statistics information by SQL query efficiently for table with 3 columns and 800 million rows

[ad_1] The OP probably already knows this, but here is how to get the answer, disregarding efficiency. First, cards per location, as described in the comments: SELECT locationid, COUNT(DISTINCT cardID) FROM table GROUP BY locationid Next the same thing per state. SELECT substring(locationid, 1, 2) state, COUNT(DISTINCT cardID) FROM table GROUP BY substring(locationid, 1, 2) … Read more

[Solved] Need Help In Sql like query

[ad_1] If I understood you need something like that: SELECT * FROM YourTable WHERE meta_value LIKE ‘% carter %’ This will work for you, because added wildcard % before and after word carter. This means, that no care what is before and after carter, It will select all results where is middle name carter More … Read more

[Solved] How to get last 3 month name in sql server

[ad_1] Sorry @Imrul Kaesh , there is some mistake on the query. I didn’t filter the last 3 months by ItemId. I have updated my query as below, please have a try: WITH Last3Month AS ( SELECT DISTINCT TOP 3 MONTH(IssueDate) AS Mth FROM Issue WHERE ItemId = 452 –Please add this WHERE Clause ORDER … Read more

[Solved] mysql reporting syntax error

[ad_1] Put your query with quotes: $query = “INSERT INTO historial(`titulo_his`, `autor_his`, `editorial_his`, `isbn_his`, `color_his`, `fecha_inicio_his`, `fecha_final_his`, `idusuarios_his`, `codlibros_his`) VALUES(‘{$tit}’, ‘{$aut}’, ‘{$edit}’, ‘{$isbn}’, ‘{$color}’, ‘{$fechaP}’, ‘{$fecha}’, ‘{$_SESSION[‘idusuarios’]}’, ‘{$libro}’)”; The problem is that you are trying to insert strings without enclosing them into quotes, so the query will fail PS: And don’t use mysql_* functions the … Read more

[Solved] Get PHP associative array from MySQL

[ad_1] Use mysql_fetch_assoc instead of mysql_fetch_row. GetRowFromDb(“`id`,`name`,`email`”, ” WHERE `id`=’1′”, “database1”, “table1″); function GetRowFromDb ($column, $condition, $database, $table) { $target=”`$database`.`$table`”; $query=”SELECT $column FROM $target $condition”; $indexedrow=mysql_fetch_assoc(mysql_query($query)); return $indexedrow; } [ad_2] solved Get PHP associative array from MySQL

[Solved] MySQL Query issue with select [closed]

[ad_1] Another approach to “join” two tables: SELECT proposal.proposalID, client.name FROM client, proposal WHERE proposal.clientID = client.id; Warning: I didn’t test this. In order to understand what’s going on, I suggest you learn more about SQL Joins. Some links to get you started: http://www.w3schools.com/sql/sql_join.asp http://en.wikipedia.org/wiki/Join_%28SQL%29 https://www.google.com/search?q=sql+join 2 [ad_2] solved MySQL Query issue with select [closed]

[Solved] How to select row with same value

[ad_1] You could probably get by with something like this, assuming your table is called ratings: select r.* from ratings r inner join ( select name, rating, max(value) value from ratings group by name, rating having count(distinct sport) > 1 ) q on r.name = q.name and r.rating = q.rating and r.value = q.value There … Read more

[Solved] Counting number of zeros in MySQL [closed]

[ad_1] I stripped the trailing and leading spaces from your text-formatted data and created an equivalent sample schema using SQL Fiddle. The setup looks like this: CREATE TABLE Grades (`htno` int, `sub` varchar(1), `marks` int, `credits` int) ; INSERT INTO Grades (`htno`, `sub`, `marks`, `credits`) VALUES (1, ‘a’, 15, 0), (1, ‘b’, 10, 0), (1, … Read more

[Solved] How can I get full entry from a column from on 10 characters given when the actual entry contains 20 characters and the field is in varchar? [closed]

[ad_1] How can I get full entry from a column from on 10 characters given when the actual entry contains 20 characters and the field is in varchar? [closed] [ad_2] solved How can I get full entry from a column from on 10 characters given when the actual entry contains 20 characters and the field … Read more

[Solved] Add new user to database

[ad_1] Your issue is simply syntax; you had a period instead of a comma at textBox1.Text+”‘.'”+textBox3.Text The other issue is that you need to use parameterized queries. Here is your code updated to use parameterization… private void button2_Click(object sender, EventArgs e) { Byte[] IMAGES = null; FileStream STREAM = new FileStream(IMGLOCATION, FileMode.Open, FileAccess.Read); BinaryReader BSR … Read more

[Solved] Mysql Query [0002] [closed]

[ad_1] Assuming you want a figure of 0 for any month and / or city which doesn’t have any sales, but where there are sales for other cities for that month then something like this:- Cross join a pair of subselects, one to get a list of the months used and one to get a … Read more

[Solved] SQL – can we combine AND operator and NOT IN?

[ad_1] Whether or not this is possible depends on the database server you use. Some databases (eg PostgreSQL) support row values, which allow you to do this: where (x, y) in (select colX, colY from ….) Otherwise you can do something like where exists (select 1 from … where colX = x and colY = … Read more

[Solved] Format a number 000..999 [closed]

[ad_1] It really isn’t clear where your numbers are coming from. if you just want to generate a list on the fly to you can use the connect-by syntax: select to_char(level, ‘FM00’) from dual connect by level <= 10; 01 02 03 04 05 06 07 08 09 10 For 0 to 999 just change … Read more