Is it possible to use ActiveRecord named_scopes to create one query with sql OR clauses?
When I use
Model.scope1.scope2
generated query is conjunction of these scopes.
Why doesnt this delete work to delete the whole record:
$query = 'DELETE FROM tblEvents WHERE index = $_GET["id"]';
$result = mysql_query($query, $db) or die(mysql_error($db));
Where index is variable of type int, auto_incremented in MySQL?
Open up TFS Pending Changes. Can you add / remove columns to that display? I thought it was tied to the selected query, but change the columns in that query did nothing for the results displayed in Pending Changes.
This question goes along with another one of my post that I already accepted
How do I get the "date number" in php
2010-08-24 20:00:00.000
I want to assign the current date number to a variable $current_date_num so I can use it in my query to compare what is already in the database.
$query ="SELECT * FROM Reservations WHERE [Room_ID] = '$field' AND [Meeting Start] > '$current_date_num' ORDER BY [Meeting Start] asc ";
Is it possible to use the criteria api to load a set of parent objects along with a filtered, eagerly loaded set of child objects? I'm trying to query a list of categories and at the same time load the categories products that start with the letter M. The query below gives me the results I want but the Products are not eagerly loaded, that is NHibernate performs additional queries when I enumerate the Product collection:
var categoriesWithProducts = session.CreateCriteria<Category>()
.SetFetchMode("Products", FetchMode.Eager)
.CreateCriteria("Products")
.Add(Expression.Like("Name", "M%"))
.List<Category>();
What am I missing here?
Following is my SQL fiddle:
http://sqlfiddle.com/#!2/f9bae/1
In which i am trying to check if the whole name is being verified by lookup table or not and if there is any error then it should get replaced by the correct value but the problem i am facing is that if any name contains more than one wrong values then query only update one part of that name and leave the rest unchanged , kindly let me know how can i modify my query for update so it'll update the whole name as per lookup table correct values.
Thanks,
Hi everyone,
I have just made the update/add/delete part for the "Closure table" way of organizing query hierarchical data that are shown on page 70 in this slideshare: http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back
However, I have a bit of an issue getting the full tree back as an multidimensional array from a single query.
Here's what I would like to get back:
array (
'topvalue' = array (
'Subvalue',
'Subvalue2',
'Subvalue3' = array ('Subvalue 1',
'Subvalue 2',
'Subvalue 3'
)
);
);
This is my query
SELECT Fullname, rank, id_no, TIN, birthdate,
hair, eyes, Blood, height, weight, marks, name, address
FROM [******_DOMAIN\****_*****].*******view
Problem is, source table has too many duplicates, how do I my limit query to the latest row on the database?
I'm using SQL Server 2008.
Thanks In advance
My next problem is that the view shows me a birthdate string format of yyyymmdd, I need to change it to mm/dd/yyyy can please provide me a function? using the same string above?
Why Nibernate HQL can not handle the following query:
from Deal D where (D.ApprovalDate + INTERVAL 1 Year) < current_timestamp() < (D.RenewalDate + INTERVAL -1 Year)
knowing that INTERVAL and YEAR are keywords in MySQL, so this is kind of mixing Sql within Hql (unless Hql can handle date functions like so and I don't know) . The dialect is MySQLDialect
Its perfectly valid to execute this query
SELECT '2005-01-01' + INTERVAL 1 Year;
What would be appropriate scenario when stored procedures should be used?
I stumbled upon implementation where almost whole data manipulation was handled by store procedures, even simplest form of INSERT/DELETE statements were wrapped and used via SP's.
So, what's the rationale for using stored procedures in general?
Sorry for such a beginners question..
Hi,
In Sql Server when you select to modify a SP or UDF it loads the objects alter query in a query window. Are these queries accessible in a system table so I can store the alter statements somewhere? It looks like syscomments has some objects but not all of them.
Thanks
I am doing this in my code,
HOST = '192.168.1.3'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
query_details = {"page" : page, "query" : query, "type" : type}
s.send(str(query_details))
#data = eval(pickle.loads(s.recv(4096)))
data = s.recv(16384)
But I am continually getting EOF at the last line. The code I am sending with,
self.request.send(pickle.dumps(results))
Hi there, im trying to do a comparison in MYSQL but wish for it to be case sensitive
ex:
$userID="test"
$q = db_query("select * from users where user_id = '" . $userID . "'");
In DB:
userid = "TEST"
Ho do i go about making sure the mysql query does not return TRUE for this query as the userid varialbe doesnt match the case of the userid in the database
thanks
i am trying to query from a temp table,and i keep getting the message
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '.
can somebody tell me wats the problem..is it due to convert..
plz help
The query is
select compid,2, convert(datetime, '01/01/' + CONVERT(char(4),cal_yr) ,101) ,0, Update_dt, th1, th2, th3_pc , Update_id, Update_dt,1
from #tmp_CTF
I have written a simple delete query
delete from mails
While I execute I get no problem and the query runs fine, but when I publish the website I get an error stating:
"Could not delete from specified
tables"
What might be the problem?
I am getting this error when placed in IIS but when i run it in local drive through visual studio i am not getting this error...please help
What is the best way to assemble an SQL query with join conditions dynamically? I don't want to hard code the query for each different condition on a webpage or a set of webpages. Is it even feasible?
I got as far as being able to assemble simple queries but i got stumped when i needed to insert join conditions, i.e. how to figure out dependencies for joins etc.
I'm trying to run a rather large query that is supposed to run nightly to populate a table. I'm getting an error saying Incorrect key file for table '/var/tmp/#sql_201e_0.MYI'; try to repair it but the storage engine I'm using (whatever the default is, I guess?) doesn't support repairing tables.
how do I fix this so I can run the query?
In my web application, I have a dynamic query that returns huge data to datatable, and this query is often recalled with different parameters. So database is exhausted.
I want to get all record with no parameters to an object, and perform queries (may be with linq) on this object. So database will not be exthausted.
Which objects can be used instead of datatable?
Is it possible to get the duplicate count when executing MySQL "INSERT IGNORE" statement via JDBC?
For example, when I execute an INSERT IGNORE statement on the mysql command line, and there are duplicates I get something like
Query OK, 0 rows affected (0.02 sec)
Records: 1 Duplicates: 1 Warnings: 0
Note where it says "Duplicates: 1", indicating that there were duplicates that were ignored.
Is it possible to get the same information when executing the query via JDBC?
Thanks.
In a program I am writing I am doing a lot of string manipulation. I am trying to increase performance and am wondering if using char arrays would show a decent performance increase. Any suggestions?
On a webpage, is it possible to split large files into chunks before the file is uploaded to the server? For example, split a 10MB file into 1MB chunks, and upload one chunk at a time while showing a progress bar?
It sounds like JavaScript doesn't have any file manipulation abilities, but what about Flash and Java applets?
This would need to work in IE6+, Firefox and Chrome. Update: forgot to mention that (a) we are using Grails and (b) this needs to run over https.
hi,
i have a query regarding to insert data in multiple table..
i have a two tables. one is item table and second is field table.
i want to insert data in both table with one query at a time.
any idea about it.
I am using Netbeans and s60 3rd version and i have completed contact manipulation which is working fine with emulator and now i want it to be work on s60 device so what are the steps to do this?
Thanks in advance..
Hi all, I have this functions and need to make it one function. The only difference is type of input variable sourceColumnValue. This variable can be String or Integer but the return value of function must be always Integer.
I know I need to use Generics but can't do it.
public Integer selectReturnInt(String tableName, String sourceColumnName, String sourceColumnValue, String targetColumnName) {
Integer returned = null;
String query = "SELECT "+targetColumnName+" FROM "+tableName+" WHERE "+sourceColumnName+"='"+sourceColumnValue+"' LIMIT 1";
try {
Connection connection = ConnectionManager.getInstance().open();
java.sql.Statement statement = connection.createStatement();
statement.execute(query.toString());
ResultSet rs = statement.getResultSet();
while(rs.next()){
returned = rs.getInt(targetColumnName);
}
rs.close();
statement.close();
ConnectionManager.getInstance().close(connection);
} catch (SQLException e) {
System.out.println("???????? ?? ???? ?? ???? ?????????!");
System.out.println(e);
}
return returned;
}
// SELECT (RETURN INTEGER)
public Integer selectIntReturnInt(String tableName, String sourceColumnName, Integer sourceColumnValue, String targetColumnName) {
Integer returned = null;
String query = "SELECT "+targetColumnName+" FROM "+tableName+" WHERE "+sourceColumnName+"='"+sourceColumnValue+"' LIMIT 1";
try {
Connection connection = ConnectionManager.getInstance().open();
java.sql.Statement statement = connection.createStatement();
statement.execute(query.toString());
ResultSet rs = statement.getResultSet();
while(rs.next()){
returned = rs.getInt(targetColumnName);
}
rs.close();
statement.close();
ConnectionManager.getInstance().close(connection);
} catch (SQLException e) {
System.out.println("???????? ?? ???? ?? ???? ?????????!");
System.out.println(e);
}
return returned;
}