473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

optional select

bilibytes
128 100+
hi,

i was wondering if it is possible to make a SELECT query with some optional fields.

i have "Object", "Info", "Image" Tables

the object contains the id and name of objects,
the info contains the additional information of each object and
the Image contains the image of each object.

BUT, not all objects have an image so when i perform this query:

Expand|Select|Wrap|Line Numbers
  1. SELECT o.name, inf.descritpion, inf.price, img.blob
  2. FROM object o, info inf, image img
  3. WHERE o.object_id = "12341234"
  4. AND inf.object_id = o.object_id
  5. AND img.object_id = o.object_id
  6.  
i get 0 results if the object has no image associated....

How could i perform this query to get all the results i query excepting those that don't exist?

I am figuring out now a solution to the problem, but it would populate the image table inefficiently:
when someone ads an object, without image, insert a row into images with the object id and with a default value for the image.

This would prevent from returning 0 results, but would also populate the "Image" Table unnecessarily

So if there is a query that allows you to make sort of a try{} please let me know

Thankyou,

bilibytes
Nov 12 '08 #1
1 2039
r035198x
13,262 8TB
Use RIGHT JOIN. i.e select from object right join image.
See the details in the reference manual.
Nov 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Eric Anderson | last post by:
I'm not sure if this is the correct place to post this question so please feel free to redirect me if needed. I am writing a XSL transform document to perform a transform on an XML document. I...
8
by: Gene Ariani | last post by:
Is there an elegant way to have an optional parameter in sql string like Select * from Name where (mytextbox is empty select everyone else select lastname=mytextbox) Any direction is...
3
by: Winshent | last post by:
I want to pass optional arguments to build up varios strings, is this possible? look at arrTBL(1,3) in the code below: =========================================== Public Function...
8
by: Alan J. Flavell | last post by:
What I was trying to do: to offer a default stylesheet, plus another small stylesheet which can be applied additionally to the default one. Preferably, the optional stylesheet should be initially...
1
by: Woodies_46 | last post by:
Hello all, I've just hit a brick wall. What I have is a form with a heap of tick boxs and text box on it and down the bottom a subform with shows the results. i also have a search button down...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
1
by: Tookelso | last post by:
Hello, I would like to have a group of elements which are *required* in one context, but each one is *optional* in another context. For example: I have a configuration file which has a...
4
by: Mark Baldwin | last post by:
I have a web page with various controls that supply parameters to an ObjectDataSource. The ObjectDataSource has various methods that allow for filtering of the results...GetProductsByID(),...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.