Query:
select emp.empname as Name, dep.depname as Department
from Employee as emp
inner join Department as dep on emp.depid=dep.depid
where emp.id='2'
How can I change this to linq to sql?
I got a list of objects in the following query. How to delete items in the middle, saying I want to delete item in 2, 5, and 7 position? thanks
var archivedPwds = from archivedPwd in db.PasswordArchive
where archivedPwd.UserId == userId
orderby archivedPwd.DateChanged
select archivedPwd;
Is it possible to query for the SQL Server 2008 service startup parameter values using T-SQL? I'm specifically looking for the -g parameter that indicates how much memory that SQL Server will leave available for memory allocations within the SQL Server process, but outside the SQL Server memory pool [msdn reference].
In SQL, can we always write an inner join statement as a main query and subquery?
For example,
select * from gifts g where g.giftID in (select giftID from sentGifts);
can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery?
I know there is a limited version of a LIKE query in the App engine's datastore where you can only search on the end of a string but I can't seem to find the syntax.
I want to do something like this
SELECT *
FROM MyTable
WHERE name LIKE ji%
Hey guys,
i was wondering, can a parameter be used more then once in the same query, like this :
MySqlParameter oPar0 = new MySqlParameter("e164", MySqlDbType.String);
oPar0.Value = user.E164;
string sSQL0 = "Delete from callmone.call where (caller=?e164 or called=?e164);";
clsDatabase.ExecuteSQL(sSQL0, oPar0);
Is this possible or should i write 2 parameters?
Hi,
Is it possible to get the query result in .CSV file format from SQL SERVER 2000 and above versions?
If so can we use this feature from an asp.net application to get the result in CSV format?
If so how can we do this?
I have following code :
try {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", year);
return this.template.getJdbcOperations().query(
"SELECT * FROM INCOME WHERE PROVNUM=? AND FISCALDATE IN ( :ids )", this.rowMapper, parameters);
}catch (EmptyResultDataAccessException ex) {
return null;
}
But i am not able to send the value for PROVNUM. how to do that?
need help,
thanks.
What SQL query should I perform to get the result set expected, giving the first element of the chain (2) as input data, or any of them ?
table name: changes
+----+---------------+---------------+
| id | new_record_id | old_record_id |
+----+---------------+---------------+
| 1| 4| 2|
| -- non relevant data -- |
| 6| 7| 4|
| -- non relevant data -- |
| 11| 13| 7|
| 12| 14| 13|
| -- non relevant data -- |
| 31| 20| 14|
+----+---------------+---------------+
Result set expected:
+--+
| 2|
| 4|
| 7|
|13|
|14|
|20|
+--+
I know I should consider change my data model, but: What if I couldn't?
Thank you in advance!
Hi, I inserted some error record to my table, I can query via the sql below and found hundards of record marked with half.
SELECT * FROM `marathon`
WHERE gender = 'male' && distance = 'half';
How to write a SQL then I can modify the result rows distance from 'half' to 'full'.
Thank you.
I notice my query doesn't behave correctly if one of the like variables is empty:
SELECT name
FROM employee
WHERE name LIKE '%a%'
AND color LIKE '%A%'
AND city LIKE '%b%'
AND country LIKE '%B%'
AND sport LIKE '%c%'
AND hobby LIKE '%C%'
Now when a and A are not empty it works but when a, A and c are not empty the c part is not excuted so it seems?
How can I fix this?
If I have a linq query that creates the anonymous type below:
select new
{
lf.id,
lf.name,
lf.desc,
plf.childId
};
Is it possible to assign a specific type to one of the members? Specifically I would like to make lf.id a null-able int rather than an int...
I have a table with an 'expires' datetime column. I want to find all the items that have an 'expires' date earlier than now.
I've tried
session.query(Item).filter(Item.expires < now())
but it doesn't return anything regardless of the dates in the table.
I'm using PostgreSQL 8.4.
How do I do this comparison?
I'm working with PreparedStatement with MySQL server.
example:
String myQuery = "select id from user where name = ?";
PreparedStatement stmt = sqlConnection.prepareStatement(myQuery);
stmt.setString(1, "test");
stmt.executeQUery();
ResultSet rs = stmt.getResultSet();
How can I receive the full SQL query that is about to be executed on the MySQL server?
thanks!
In a WPF app I'd like to check if a return of a LINQ to SQL query contains some records, but my approach doesn't work:
TdbDataContext context = new TdbDataContext();
var sh = from p in context.Items where p.Selected == true select p;
if (sh == null)
{
MessageBox.Show("There are no Selected Items");
}
Where am I wrong?
here we got a positional parameter:
SELECT
u
FROM ForumUser u
WHERE u.id = ?1
and here a named parameter:
SELECT
u
FROM ForumUser u
WHERE u.username = :name
this is DQL (doctrine query language) but i think the concept is the same.
could someone please explain what these mean and do?
I want to improve the performance of this update query because when it take lots of time to execute:
Qry = "update tab1 set cDate=GetDate() where right('000000000000'+in_num,12)='" & InvNo.PadLeft(12, "0") & "' and (Total-Amount)<>Balance <>Balance and cDate is null"
I have a table with three columns: patient_id, obs_date, and weight_val. patient_id stores patient identification #, weight_val stores a weight value, and obs_date stores the date when the weight reading was taken. So, a patient can have many different weight readings at different dates.
How do you write a query for:
select all patients whose last weight reading is 120?
Whats query can be used to get the details of Indexes of any table? I need this to find out primarykey/autoincremented value of any table..
Please help/Guide me...
Can "Distinct" key Word be used twice in a single Select Query? like wise:
select DISTINCT(trackid), DISTINCT(table_name) from jos_audittrail where live = 0 AND operation = UPDATE
Thanks
i would like to do something like this:
DoCmd.OpenQuery "select * from some_table;"
how would i do this?
please keep in mind i don't want create a new query, save it, and run it, i just want to type the select statement in the vba code and run it.
Is it possible to write a query that will give me the names of all the tables in an SQL Server database? I'm working on some 'after the fact' documentation on a system I didn't create and am looking for a shortcut to get a listing of the tables in a database.
Hi guys,
Can I use TSQL to operate on normal operating system files? Such as create a .bat file at c:\test and write some query result into that batch file?
Thanks.
I'm going to optimize a MySQL embedded query with a view, but I'm not sure whether it will give an effect:
SELECT id FROM (SELECT * FROM t);
I want to convert it to:
CREATE VIEW v AS SELECT * FROM t; SELECT id FROM v;
I've heard about "indexed views" in SQL Server, but I'm not sure about MySQL. Any help would be appreciated. Thanks!