Hi Team,
I am using SQL Server 2005. I have a requirement to list out all the tables (and the column) whcih has the value 'xyzeee'.
Is there a query to achieve this?
Thanks
Lijo
Hi there,
I know that is it possible to create a View with Parameters at MSSQL, does anyone knows if I can achieve something similar with a DB2 database?
I have a more complicated query which includes a user number which I want to pass as param to the view.
I don't understand how to get the columns I want from rails. I have two models - A User and a Profile. A User :has_many Profile (because users can revert back to an earlier version of their profile):
> DESCRIBE users;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(255) | NO | UNI | NULL | |
| password | varchar(255) | NO | | NULL | |
| last_login | datetime | YES | | NULL | |
+----------------+--------------+------+-----+---------+----------------+
> DESCRIBE profiles;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | MUL | NULL | |
| first_name | varchar(255) | NO | | NULL | |
| last_name | varchar(255) | NO | | NULL | |
| . . . . . . |
| . . . . . . |
| . . . . . . |
+----------------+--------------+------+-----+---------+----------------+
In SQL, I can run the query:
> SELECT * FROM profiles JOIN users ON profiles.user_id = users.id LIMIT 1;
+----+-----------+----------+---------------------+---------+---------------+-----+
| id | username | password | last_login | user_id | first_name | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
| 1 | john | ****** | 2010-12-30 18:04:28 | 1 | John | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
See how I get all the columns for BOTH tables JOINED together? However, when I run this same query in Rails, I don't get all the columns I want - I only get those from Profile:
# in rails console
>> p = Profile.joins(:user).limit(1)
>> [#<Profile ...>]
>> p.first_name
>> NoMethodError: undefined method `first_name' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in `method_missing' from (irb):8
# I do NOT want to do this (AKA I do NOT want to use "includes")
>> p.user
>> NoMethodError: undefined method `user' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in method_missing' from (irb):9
I want to (efficiently) return an object that has all the properties of Profile and User together. I don't want to :include the user because it doesn't make sense. The user should always be part of the most recent profile as if they were fields within the Profile model. How do I accomplish this?
Hi there.
Using mysql and php
Is there any reason / value when checking a password to query the database using the user name and password (after sanitizing, of course) and recording a failed attempt when no rows are returned vs querying the database using the user name and then comparing the return password string?
EDIT: To those who mentioned it below, yes the password is hashed up in the database.
i need to make a php code for checking hotel room avaibility where user from the present day can book rooms upto 90 days or less and there are total 30 rooms available in the hotel,so if once i store the data for a user like his booking from one date till another next time if i want to check the avaibility how should i do it in php,what would be the logic.
obviously i simple query like this isn't correct
for eg
$this->db->select('*')
->from('default_bookings')
->where('booking_from <',$input['fromdate'])
->where('booking_till >',$input['tilldate']);
Is it possible to set a varaible to a query result such as:
DECLARE result INT;
SET result = (SELECT index FROM table WHERE data = 'xxxx' LIMIT 1);
Assuming of course you know that there will only be one result set
Hi, I am trying to get a xpath query using the xpath function lower-case or uppper-case, but they seem to not work in selenium (where I test my xpath before I apply it).
Example that does NOT work:
//*[.=upper-case('some text')]
I have no problem locating the nodes I need in complex path and even using aggregated functions, as long as I don't use the upper and lower case.
Has anyone encountered this before? Does it make sense?
Thanks.
I am overriding the admin fieldset.html template?
I need to access the model.
I have a table called domain and I need to query the database (Domain.objects.all) get a list of all the domains and pass it to the template.
How/where would I do it especially with respect to admin interface.
Thanks
Am trying to construct a simple update query in my model
class Model_DbTable_Account extends Zend_Db_Table_Abstract
{
protected $_name = 'accounts';
public function activateaccount($activationcode)
{
$data = array(
'accounts_status' => 'active',
);
$this->update($data, 'accounts_activationkey = ' . $activationcode);
}
However I get an
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'my activation code value'
in 'where clause'
error.
What am I missing in Zend_Table update construct?
I have a table like
Employee
==================
name salary
==================
a 10000
b 20000
c 5000
d 40000
i want to get all the employee whose salary is greater than A's salary.
I don't want to use any nested or sub query.
It has been asked in an interview and hint was to use self join. I really can't figure out how to achieve the same.
Hi all,
I using the SQL Server 2008 FTS feature in a project. When searching for a phone number like CONTAINSTABLE(table, *, '"01739470869"'), this query also returns records containing the number '01739468996', which is similar. Does anyone know how I can get an exact match from a number?
The SQL query without where statement runs great and outputs good results, but when I include WHERE condition it shows Unknown column 'date1' in 'where clause'. What's the problem?
SELECT IF(e.weekly, DATE_ADD(DATE(e.time), INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK), DATE(e.time)) AS `e.date1`, `v`.`lat`, `v`.`lng`
FROM `events` AS `e`
INNER JOIN `venues` AS `v` ON e.venue_id = v.id WHERE e.date1 > '2010-09-01'
Does all the columns in select statement gets selected one after another as listed?
Declare @X, @Y
SELECT
@X = ColumnA*.25 + ColumnB*2.5,
@Y = ColumnA*.5 + ColumnC*1.33,
TOTAL = @X + @Y
FROM SomeTable
Is the above query safe to use? Will total always be selected after @X and @Y are calculated?
<rule name="Query String Redirect">
<match url="home/address\.aspx\?city=jcity$" />
<action type="Redirect" url="city/jerseycity" appendQueryString="false"/>
</rule>
This does not work. What should be done to make it work?
Given an Oracle Merge statement with a rejection limit, is there a shorthand way to identify how many rows were rejected, without being forced to query the rejection destination?
The rejection destination has records pre-merge, so would currently have to be counted twice and the difference taken, but it seems like there should be a counter exposed, given that it has to be aware of whether it has exceeded the rejection limit.
Hi
I have a MS SQL database running (MS SQL 2005) and am connecting to it via the net.sourceforge.jtds.jdbc.Driver.
The query works fine for all the columns except one that is a varchar(max). Any ideas how to get around this issues?
I am using the jdbc driver to run a data index into a SOLR implementation.
(I do not control the database, so the first prize solution would be where I can tweak the SQL command to get the desired results)
Thanks
Say I have a table 'People', is there a way to just quickly check if a People object exists with a name of 'Fred'? I know I can query People.objects.filter(Name='Fred'), and then check the length of the returned result, but is there a way to do it in a more elegant way?
What is the best scala-like persistence framework available right now?
Hibernate works, but it's not very scala-like. It insists on using annotations, no-arg constructors, doesn't work with anonymous class instances, doesn't work with scala collections, has an outdated string-based query model, etc.
I'm looking for something that really fits Scala. Does it exist? Or do I have to make it?
For invoke search android example, every time query search result is received by onCreate().
How can i make it received by onNewIntent(). What kind of operation can cause onNewIntent() receive intent?
Hello Experts,
I have data like this
d b c
a d
c b
a b
c a
c a d
c
if you analyse, you will find the appearance of each element as follows
a: 4
b: 3
c: 5
d: 2
According to appearance my sorted elements would be
c,a,b,d
and final output should be
c b d
a d
c b
a b
c a
c a d
c
Any clue, how we can achieve this using sql query ?
When I turn on output caching for my service it doesn't appear to be cache-worthy in IIS. It really should be since I'm returning the same JSON content over and over. The varyByQueryString option seems like it would do the trick, but since my resources are URI based, there really isn't a query string, just a path to a resource. Has anyone successfully gotten IIS to output cache a WCF REST service?
In an auto-generated chart based on a query (I dragged the chart object onto a blank form to start it), the chart itself is displaying and updating properly, datawise, but I want to change the Legend from reading "SumOfAvgOfield1" and "SumOfAvgOfield2" to regular words suitable for final presentations. But I can't find a way to change it!
I have a bunch of int key fields in my index and trying to do a simple range search like this:
`gender:1 AND height:[120 TO 180]`
This should give me male in the height range 120 to 180. But for some reason i get this exception:
`At least one range query boundary term must be non-empty term`
How would i debug this? Is it just Zend_Search_Lucene being buggy?
How long can a URL be? I want to pass a lot of data through the query string. I think I remember that it depends on what different routers it passes through, but how long can the URL be and definitely not get truncated?
HI Guys,
Here I a wanna know that whether sqlite supports SELECT INTO statement.
Actually I am trying to save the data in my table1 into table2 as a backup of my database before modifying the data.
for that when I am using the SELECT INTO Statement a syntax error was generating as:
My query as:
SELECT * INTO equipments_backup FROM equipments;
"Last Error Message:near "INTO":syntax
error".
Anyone's help will be appreciated.
Thank you,
Monish.