首页 \ 问答 \ 基于来自单独数据库的ID更新表(Updating table based on IDs from seperate database)

基于来自单独数据库的ID更新表(Updating table based on IDs from seperate database)

我需要从DATABASE_2的ID_2将ID_1从DATABASE_1切换到ID_2,其中DATABASE_1.ID_1 = DATABASE_2.ID_3

UPDATE `table_1` 
SET `DATABASE_1`.`table_1`.`ID_1`= `DATABASE_2`.`table_2`.`ID_2`
WHERE `DATABASE_1`.`table_1`.`ID_1` = `DATABASE_2`.`table_2`.`DealerID`

以上是我正在考虑的声明类型。 这是结构

DATABASE_1
table_1
    ID_1
    1
    2
    3
    4
    5

DATABASE_2
table_2
    ID_2            ID_3
    10              1               
    20              2
    30              3
    40              4
    50              5

我想我需要以某种方式加入这些...或将列添加到table_1上并进行更改。 我很难加入,到目前为止,我有

SELECT ID_2 , ID_3 FROM DATABASE_2.table_2 t2 JOIN DATABASE_1.ID_1 t2 ON t1.ID_1 = t2.ID_3

但不会更新它...


I need to switch ID_1 from DATABASE_1 to ID_2 from ID_2 from DATABASE_2 where DATABASE_1.ID_1 = DATABASE_2.ID_3

UPDATE `table_1` 
SET `DATABASE_1`.`table_1`.`ID_1`= `DATABASE_2`.`table_2`.`ID_2`
WHERE `DATABASE_1`.`table_1`.`ID_1` = `DATABASE_2`.`table_2`.`DealerID`

Above is the type of statement I was thinking of. Here is the structure

DATABASE_1
table_1
    ID_1
    1
    2
    3
    4
    5

DATABASE_2
table_2
    ID_2            ID_3
    10              1               
    20              2
    30              3
    40              4
    50              5

I think I need to JOIN these somehow... or add columns onto table_1 and alter them. I am bad at joining, and so far I have

SELECT ID_2 , ID_3 FROM DATABASE_2.table_2 t2 JOIN DATABASE_1.ID_1 t2 ON t1.ID_1 = t2.ID_3

but that doesn't update it...


原文:https://stackoverflow.com/questions/32361906
更新时间:2023-03-07 11:03

最满意答案

在你的相机上有一个静态宽度是完全可以的,因为它给你的游戏一个固定的维度,你可以可靠地工作。 这是有效的,因为相机用于定义世界坐标,这些坐标并不总是与屏幕坐标一对一。

您的问题来自固定的相机高度。 具有固定高度将导致屏幕伸展得更高或更短,具体取决于设备屏幕的纵横比。 如果您想考虑不同的长宽比,则需要将显示比例乘以相机高度(当前为480)。 您可以通过将高度除以宽度除以高度来获得屏幕比例。 这看起来像是这样的:

float width = Gdx.graphics.getWidth();
float height = Gdx.graphics.getHeight();

OrthographicCamera camera = new OrthographicCamera(800, 480 * (height / width));

正如BennX在评论中指出的那样,LibGDX引入了视口,它允许你以不同的方式完成与上面相同的事情。 为了达到与上面概述的效果相同的效果,只需使用视口,就可以使用ExtendViewport 。 这样做是为了在一个方向上保持世界尺寸,同时在另一个方向上拉伸它。 因此,世界将首先扩大以填充屏幕,然后在保持纵横比的同时扩展较短的尺寸。 要创建这种类型的视口,它看起来像这样:

OrthographicCamera camera = new OrthographicCamera(800, 480);
ExtendViewport viewport = new ExtendViewport(800, 480, camera);

上面的视口的最小宽度为800,最小高度为480.在应用视口后,其中一个值将相同,另一个值将根据屏幕的高宽比进行更改。 更窄的屏幕将具有更多的垂直空间,而更宽的屏幕将具有更多的水平空间。 有关视口的更多信息,请访问LibGDX wiki页面。


Having a static width on your camera is perfectly ok as it gives your game a single fixed dimension that you can work with reliably. This works because the camera is used to define world coordinates which are not always one to one with screen coordinates.

Your issues come from the fixed camera height. Having a fixed height will cause your screen to stretch taller or shorter depending on the aspect ratio of the device screen. If you want to account for the different aspect ratios, you'll need to multiply your camera height (currently 480) by the display ratio. You can get the screen ratio by dividing the height by the width by the height. This would look something like:

float width = Gdx.graphics.getWidth();
float height = Gdx.graphics.getHeight();

OrthographicCamera camera = new OrthographicCamera(800, 480 * (height / width));

As pointed out by BennX in the comments, LibGDX introduced viewports which allow you do very much the same thing as above, just in a different way. To achieve the same effect as I outlined above, only using a viewport, you'd use an ExtendViewport. What this does is maintain the world size in one direction while stretching it in the other direction. So the world will first scale up to fill the screen, then the shorter dimension is expanded while maintaining aspect ratio. To create this type of viewport, it'd look something like this:

OrthographicCamera camera = new OrthographicCamera(800, 480);
ExtendViewport viewport = new ExtendViewport(800, 480, camera);

The viewport above will have a minimum width of 800 and a minimum height of 480. One of these values will be the same after the viewport is applied and the other will change based on the aspect ratio of the screen. More narrow screens will have more vertical space while wider screens will have more horizontal space. For more on viewports, visit the LibGDX wiki page here.

相关问答

更多
  • 另一种方法是使用ViewBox: 例如: 现在,当您调整窗口大小时,所有元素也将调整大小 ...
  • 下面是我完全从Android开发人员的角度给出的答案(我对PhoneGap没有经验,所以我不能说这是如何影响的): 对于我的大部分测试,我专注于320x480和480x800。 对于平板电脑,您也想要专门针对Galaxy Tab进行测试(有关仿真器测试的更多详细信息,请参阅Samsung网站 )。 Android中的布局通常设计(或应该)以支持任何屏幕尺寸。 通常,视图设置为MATCH_PARENT(以前为FILL_PARENT)或WRAP_CONTENT,因此它们的大小取决于它们所在的布局或其包含的内容, ...
  • 我不能直接回答你的问题,但我想告诉你我的做法。 我尽量不要使用任何数字。 相反,我尝试使用paddings,边距和相对布局,以便我的视图在任何手机上看起来都正确。 它也帮助我避免为不同的方向创建视图。 I found a clear answer to the problem. Minimum resolutions are undefined prior to 3.0. So for 3.0 and above it will be possible to choose a minimum resolut ...
  • 最好和最简单的方法是 在android studio中转到项目的android文件夹 然后在src子文件夹中找到AndroidLauncher.java 然后复制并粘贴下面的代码 @Override protected void createWakeLock(boolean use){use = true; super.createWakeLock(使用); } 添加代码后整个文件将如下所示 公共类AndroidLauncher扩展AndroidApplication {@Override protecte ...
  • FillResolutionPolicy会根据您的屏幕大小自动缩放所有内容。 Camera camera = new Camera(0, 0, 480, 880); EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), this.camera); 这就是我使用的,如果我在更大的设备上启动游戏,一切都会自动缩放。 FillResol ...
  • 我从来没有使用过XNA,但通常只是为了解决这类问题,你需要从屏幕的实际分辨率中抽象出精灵的位置。 这意味着您可以使用绝对坐标存储对象位置(例如,在范围0.0f - 1.0 ),以便x = 0.0是最左边的像素可见, 1.0是y坐标的最右边,相同的故事。 然后根据此坐标空间计算所有内容,并且您担心在实际绘制之前转换它们。 当然,对于这种方法,您需要具有不同的大小,必须以独立于分辨率的方式保持相同的比例。 例如,如果你有1080p,那么你选择64x64精灵,1080/64给出16.875,所以对于720p分辨率 ...
  • 我在LibGDX上使用了几个具有不同分辨率的SpriteSheets,原因如下: 当您必须支持屏幕分辨率范围为320 * 480到2560 * 1400(并且可能在几年内达到4K)的设备时,几乎不可能在所有这些屏幕上以独特的spritesheet分辨率获得完美的结果。 如果您使用虚拟屏幕分辨率(视口),您可以使用单个分辨率并相应地创建资源,并让此视口自动缩放到屏幕,以便您的游戏在任何设备上看起来都一样。 因此,有人可能认为单个HD spritesheet可能就足够了。 但是,大多数低成本或旧的移动设备有时无 ...
  • 这很容易。 你基本上是为你的原始分辨率构建你的整个程序,但是在处理定位和纹理大小的所有事情上都有这样的情况: private void resize() { float x = Gdx.graphics.getWidth(); float y = Gdx.graphics.getHeight(); float changeX = x / assumeX; //being your screen size that you're developing with float c ...
  • 在你的相机上有一个静态宽度是完全可以的,因为它给你的游戏一个固定的维度,你可以可靠地工作。 这是有效的,因为相机用于定义世界坐标,这些坐标并不总是与屏幕坐标一对一。 您的问题来自固定的相机高度。 具有固定高度将导致屏幕伸展得更高或更短,具体取决于设备屏幕的纵横比。 如果您想考虑不同的长宽比,则需要将显示比例乘以相机高度(当前为480)。 您可以通过将高度除以宽度除以高度来获得屏幕比例。 这看起来像是这样的: float width = Gdx.graphics.getWidth(); float heigh ...
  • 你基本上在方法show()中抛出异常,在将屏幕设置为MyGdxGame类之后立即调用它。 @Override public void show() { throw new UnsupportedOperationException("Not supported yet."); } 从未使用过NetBeans,但看起来它会覆盖show()并带有异常。 正如代码中的注释所示,在Tools |中更改生成方法的主体 模板可以避免这种错误。 You are basically throwing an exc ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)