sqlquery

SubSonic 2.1 SqlQuery multiple Where()s?

I'm building a SqlQuery to support an ad-hoc query screen. I want something like this: SqlQuery q = new Select().From<VwInstitutes>(); if (!string.IsNullOrEmpty(username)) { q.Where(VwInstitutes.Columns.AssignedUser).IsEqualTo(username); } if (!string.IsNullOrEmpty(stage)) { q.Where(VwInstitutes.Columns.Stage).IsEqualTo(stage...

Column with same name in multiple tables causing problem in SubSonic Select.

Hi folks, there are other question (at least 2 I've seen them) similar to this but I'm not able to solve this using them. Now the problem: I've 3 table from which I need to select 4 columns only. I'm using InnerJoin and it is working perfectly. Problem starts when I add a Where to this Select. I've a column named "Name" in two tables. I...

SubSonic 2.1: Need explanation of SqlQuery.ExecuteJoinedDataSet()

Hi there, I have a SqlQuery that looks like this: SqlQuery query = DB.Select( Order.Schema.TableName + ".*", OrderDetail.Schema.TableName + ".*") .From<Order>() .InnerJoin<OrderDetail>() .Where(Order.IdColumn).IsEqualTo(1); Now I wo...

NHibernate Projection using SqlQuery...

Hi, I'm trying to reproduce the HqlQuery style 'select new ObjectToProjectOut' functionality. i.e. take a list of columns returned from a query and return as a list of ObjectToProjectOut types that are instantiated using a Constructor with as many parameters as the columns in the query. This is in effect what 'select new ObjectToProjec...

How can I generate subclass joins in a NHibernate SqlQuery?

I am having problems getting NHibernate to generate a SQL query that actually runs without errors, as the query is missing joins for my subclasses. Lets take this minimal example: class Page { public virtual int Id { get; set; } public virtual string UrlSegment { get; set;} public virtual Page Parent { get; set; } } class ...

How do I prevent the query class from processing the question marks in my text strings?

Rather new to php, so sorry if this seems stupid. I'm really copying a lot of this from previously written code from other developers at my company. The way we run a query is basically like this: $qry = new SQLQuery; $sqlString = "SELECT * FROM database.table WHERE table.text = '" . $textVar . "' and table.text2 = '" . $...

Nhibernate - Getting Exception executing SQL Query

Hi, I am excuting SQL Query using Nhibernate, here is my code public ArrayList getDocumentsForApproval(string ReleaseId) { string query = string.Format("SELECT distinct doc.Id, doc.Name as Doc, doc.url as url, suser.Name as Author, ds.name, CONVERT(VARCHAR(11), doc.DateEntered, 101) as DateEntered FROM dbo.Documents doc INN...

Visual Studio 2010 Visual Query Designers?

If I want to create a project in VS2010 that lets me use the VISUAL QUERY designer - just to run a bunch of scripts etc. What project type do I use? In the transition from DBP to DBPROJ, visual studio 2010 seem to have lost this ability! In <2010 you could just add a .sql and select, right click and design... ...

SQL query to remove text within parentheses?

What is the best SQL query to remove any text within parenthesis in a mySQL database? I'd like something that works regardless of the position of the parenthesis in the text (beginning, middle, end, whatever). I don't care about keeping the text inside the parenthesis, just removing it. Thanks! ...

sql query question

hey guys, just having a bit of difficulty with a query, i'm trying to figure out how to show the most popular naturopath that has been visited in a centre. My tables look as follows; Patient(patientId, name, gender, DoB, address, state,postcode, homePhone, businessPhone, maritalStatus, occupation, duration,unit, race, registrationDate ...

Help with sql query on the same table.

My table (ProjectList) columns are: ProjectId, MainProjectId, SecondaryProjectId, ProjectName, EndDate I need to write a query that brings me all the rows from this table where EndDate <= 40394 and for each ProjectId i need to bring again all the rows where (MainProjectId = ProjectId)OR(SecondaryProjectId = ProjectId) Example: 1, ...

Left Join with where clause

I have 3 tables A, B and C I am doing this :- /* There is no relation between Table A and Table B . Table A is just used to provide values to C.Profile */ 1st step ) D <---- Select * from C where Profile=1 // want to give a specific ProID(I have successfully retrieved it from A table) 2nd Step ) Output <--- Select B.sname,D.Status fr...

Benefit of using DBComboBox over CombBox?

So I'm messing around with a new project in Delphi 2009 and the default components that can be dropped onto a form for accessing data consist of a SQLConnection, DataSource and SQLQuery. If I add a simple select to the query component, say: select name from customers and then drop a DBComboBox on the form and link it up with the Data...

Sql query - how to get when a row first got a certain value

Hi, I have a table with rows like this: ID StatusId Date 1 1 2001-01-01 2 1 2001-01-02 3 2 2001-01-03 4 3 2001-01-04 5 1 2001-01-05 6 2 2001-01-06 7 2 2001-01-07 8 1 2001-01-08 9 1 2001-01-09 I need to g...

NHibernate/Hibernate define mapping without a class

I have a particular case where I need to define a query including a table ASpecialTable for which I don't have any mapping or business class defined. However, the return type of the query is an existing business class MyBO. For that particular table, I'll never need it in my code, and it doesn't contain a primary key, or to be short: I...

How to Insert Javascript function between sql query ??

Is there any way to insert java-script function between the query ?? For example :: In an query, i have stored date of birth like this 10101990 in the database, it means 10/10/1990, but I have display it in-front of page but in certain format like 10.10.1990 by using one java-script function. Please suggest me any way ?? ...

PostgreSql + Typecast of Boolean into Character Type

Here, I am unable to convert boolean value into character in postgre sql query. SELECT *FROM ltl_class_nmfc_aliases WHERE ltl_class_nmfc_aliases.id NOT IN(SELECT ltl_class_nmfc_aliases_id FROM commodities_shippeds WHERE commodities_shipped_obj_type LIKE 'ClientOffice') OR ltl_class_id IS NULL AND lower(commodity_description_alias) ...

PostgreSql + Escape Enter Key from Query Statement ie Enter Key pressed betweent the data.

Suppose we have a textarea in which we put example string. Textbox contain : Earth is revolving around the Sun. But at the time of saving, I just pressed a enter key after "the sun". Now the statements in texbox :: Earth is revolving around the Sun. Now I am trying to fetch the data but unable just because of that enter key press...

PostgreSql + Query Statement having \r in between the attributes !!!

Suppose we have a textarea in which we put example string. Textbox contain : Earth is revolving around the Sun. But at the time of saving, I just pressed a enter key after "the sun". Now the statements in texbox :: Earth is revolving around the Sun Now, in database where enter was pressed the \r is stored. Now i am trying to fetch...