How to fetch unique(PKID, Column1,column2) from mySQL? [closed] - mysql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Could anybody let me know that how can i fetch unique(PKID, Column1,column2) values from my_table in mySql?

You can either use Ozzyberto's way, which should work, or you could use GROUP BY:
SELECT PKID,Column1,Column2
FROM my_table
GROUP BY PKID,Column1,Column2
sqlfiddle demo

You must be looking for the DISTINCT keyword:
http://www.w3schools.com/sql/sql_distinct.asp
You would need the following query:
SELECT DISTINCT PKID, Column1,column2 FROM my_table

Related

Select rows between X number and Y number [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
so let's say I have 5000 rows, I want to select the rows from 2000 to 3000 only, how to do that via a SQL query?
Try this
select * from table limit 2000,1000
limit from,how-many

Can I simulate that my MySql field is an array [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I simulate that my MySQL field is an array, and later with some query to search element in that array ?
In only MySql:
To get the field.
select FIELDNAME from TABLE
To search from that result set:
select FIELDNAME from TABLE where FIELDNAME like '%myvalue%'
The %'s are wild cards. This would return any value with myvalue in it.
Such as:
(amyvalue, bmyvalueb, I<3myvaluecompletely)
If you want this done in some language you need to provide a more verbose and detailed question.

Mysql query search one column and replace another [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've got a large database table and wanting to select rows in the column 'cat_id' containing the value "79", then replace all the values in a column called "system" with the value "6" for the selected rows.
This query will do that:
UPDATE `table` SET `system` = '6' WHERE `cat_id` = '79'
I could be misunderstanding you, but i think you are looking for a simple update:
UPDATE yourTable
SET system = 6
WHERE cat_id = 79;

Data Base Query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a database like this:-
state_name|district_name|id
jammu |kupwara |jk-01
kashmir |anantnag |jk-02
I want a mysql Query such that when
statename is selected (jammu), distname should be selected(kupwara) based on thier id.
If any one knows please help me out.Thanks in Advance
If I understood your question properly, then query should be like this
SELECT state_name,district_name from TableName WHERE id='jk-01' //you can have your specific id here

is it possible to select running balances [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to select month(yyyy-mm),opening,debit,credit,closing
from transactions group by month(yyyy-mm);
here is the transactions table
date,debit,credit
Is it posssible in mysql alone with out php?
The easiest way is to use variables, as in:
select `date`, debit, credit, (#bal := credit - debit) as bal
from transaction t cross join
(select #bal := 0) const
order by `date`;
You can then use this for aggregation or whatever you want to do.