On Wednesday 05 October 2005 15:07, Arno Lehmann wrote:
> Hi,
>
> On 05.10.2005 14:01, Phil Stracchino wrote:
> > John wrote:
> >>I built bacula 1.36.3 from source, and that table was not created when I
> >>installed it.  What version are you using?
> >
> > Then probably Arno applied the patch when I first sent it out, but it
> > never made it into mainstream.
>
> Right, I did apply it with 1.34.something, and naturally I never deleted
> the database. I checked that it is in the (current) source, though.
>
> >  I'll regenerate the patch in a better
> > way once I get my development machine updated.
>
> The table is useful for the queries, too. For example, I have
>
> :List last 25 Jobs ordered by start time with long status:
>
> SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatusLong
> AS Status
> FROM Job
> LEFT JOIN Status ON Job.JobStatus=Status.JobStatus
> ORDER BY StartTime
> DESC
> LIMIT 25;
>
> I don't know if this is proper SQL or if it works with anything but
> MySQL - I just know from experience that joins always take me lots of
> time to figure out, and my trial-and-error method of coding doesn't
> produce very portable code ;-)

Generally, I find it much easier (at least for *my* brain) to avoid joins 
unless you want some special type and replace the above with:

> SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatusLong
> AS Status
> FROM Job, Status
> WHERE Job.JobStatus=Status.JobStatus
> ORDER BY StartTime
> DESC
> LIMIT 25;

The only downside is for any column name appearing in the SELECT clause 
(JobId,Name,...), if it is not unique in all the tables listed (Job, Status), 
then you must specify which one you want.

-- 
Best regards,

Kern

  (">
  /\
  V_V


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to